@@ -287,18 +287,13 @@ void QgsLabelDialog::changeFont( void )
287
287
#else
288
288
mFont = QFontDialog::getFont ( &resultFlag, mFont , this );
289
289
#endif
290
- if ( resultFlag )
291
- {
292
- if ( mFont .pointSizeF () != fontSize )
293
- {
294
- // font is set to the font the user selected
295
- spinFontSize->setValue ( mFont .pointSizeF () );
296
- }
297
- }
298
- else
290
+ if ( !resultFlag )
291
+ return ;
292
+
293
+ if ( mFont .pointSizeF () != fontSize )
299
294
{
300
- // the user cancelled the dialog; font is set to the initial
301
- // value, in this case Helvetica [Cronyx], 10
295
+ // font is set to the font the user selected
296
+ spinFontSize-> setValue ( mFont . pointSizeF () );
302
297
}
303
298
lblSample->setFont ( mFont );
304
299
}
@@ -307,7 +302,11 @@ void QgsLabelDialog::changeFontColor( void )
307
302
{
308
303
QgsDebugMsg ( " entering." );
309
304
310
- mFontColor = QColorDialog::getColor ( mFontColor );
305
+ QColor color = QColorDialog::getColor ( mFontColor );
306
+ if ( !color.isValid () )
307
+ return ;
308
+
309
+ mFontColor = color;
311
310
QPalette palette = lblSample->palette ();
312
311
palette.setColor ( lblSample->foregroundRole (), mFontColor );
313
312
lblSample->setPalette ( palette );
@@ -317,7 +316,11 @@ void QgsLabelDialog::changeBufferColor( void )
317
316
{
318
317
QgsDebugMsg ( " entering." );
319
318
320
- mBufferColor = QColorDialog::getColor ( mBufferColor );
319
+ QColor color = QColorDialog::getColor ( mBufferColor );
320
+ if ( !color.isValid () )
321
+ return ;
322
+
323
+ mBufferColor = color;
321
324
QPalette palette = lblSample->palette ();
322
325
palette.setColor ( lblSample->backgroundRole (), mBufferColor );
323
326
lblSample->setPalette ( palette );
@@ -326,13 +329,8 @@ void QgsLabelDialog::changeBufferColor( void )
326
329
327
330
int QgsLabelDialog::itemNoForField ( QString theFieldName, QStringList theFieldList )
328
331
{
329
- int myItemInt = 0 ; for ( QStringList::Iterator it = theFieldList.begin (); it != theFieldList.end (); ++it )
330
- {
331
- if ( theFieldName == *it ) return myItemInt;
332
- ++myItemInt;
333
- }
334
332
// if no matches assume first item in list is blank and return that
335
- return 0 ;
333
+ return std::max ( 0 , theFieldList. indexOf ( theFieldName ) ) ;
336
334
}
337
335
338
336
QgsLabelDialog::~QgsLabelDialog ()
0 commit comments