Skip to content

Commit 32aed70

Browse files
author
jef
committed
apply #2824 from Florian Hof
git-svn-id: http://svn.osgeo.org/qgis/trunk@13856 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 121931b commit 32aed70

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

CONTRIBUTORS

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Diego Moreira
1818
Faunalia (http://www.faunalia.it)
1919
Fernando Pacheco
2020
Florian El Ahdab
21+
Florian Hof
2122
Frank Warmerdam
2223
Germán Carrillo
2324
Giuseppe Sucameli

src/app/qgslabeldialog.cpp

+17-19
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,13 @@ void QgsLabelDialog::changeFont( void )
287287
#else
288288
mFont = QFontDialog::getFont( &resultFlag, mFont, this );
289289
#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 )
299294
{
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() );
302297
}
303298
lblSample->setFont( mFont );
304299
}
@@ -307,7 +302,11 @@ void QgsLabelDialog::changeFontColor( void )
307302
{
308303
QgsDebugMsg( "entering." );
309304

310-
mFontColor = QColorDialog::getColor( mFontColor );
305+
QColor color = QColorDialog::getColor( mFontColor );
306+
if ( !color.isValid() )
307+
return;
308+
309+
mFontColor = color;
311310
QPalette palette = lblSample->palette();
312311
palette.setColor( lblSample->foregroundRole(), mFontColor );
313312
lblSample->setPalette( palette );
@@ -317,7 +316,11 @@ void QgsLabelDialog::changeBufferColor( void )
317316
{
318317
QgsDebugMsg( "entering." );
319318

320-
mBufferColor = QColorDialog::getColor( mBufferColor );
319+
QColor color = QColorDialog::getColor( mBufferColor );
320+
if ( !color.isValid() )
321+
return;
322+
323+
mBufferColor = color;
321324
QPalette palette = lblSample->palette();
322325
palette.setColor( lblSample->backgroundRole(), mBufferColor );
323326
lblSample->setPalette( palette );
@@ -326,13 +329,8 @@ void QgsLabelDialog::changeBufferColor( void )
326329

327330
int QgsLabelDialog::itemNoForField( QString theFieldName, QStringList theFieldList )
328331
{
329-
int myItemInt = 0; for ( QStringList::Iterator it = theFieldList.begin(); it != theFieldList.end(); ++it )
330-
{
331-
if ( theFieldName == *it ) return myItemInt;
332-
++myItemInt;
333-
}
334332
//if no matches assume first item in list is blank and return that
335-
return 0;
333+
return std::max( 0, theFieldList.indexOf( theFieldName ) );
336334
}
337335

338336
QgsLabelDialog::~QgsLabelDialog()

0 commit comments

Comments
 (0)