Skip to content
Permalink
Browse files

Avoid project being marked dirty as soon as its opened

This is a simple workaround, not a real fix. The real fix is to
move the symbolModified signal out of the updatePreview call,
because we should be able to refresh a preview image without
marking it as a changed symbol. But that's higher risk, so deferred
to 3.8
  • Loading branch information
nyalldawson committed Jan 24, 2019
1 parent 996f486 commit 394e5d8d76480c1235c49e46d52f5f4a277cf824
Showing with 9 additions and 1 deletion.
  1. +8 −1 src/gui/symbology/qgssymbolselectordialog.cpp
  2. +1 −0 src/gui/symbology/qgssymbolselectordialog.h
@@ -309,8 +309,10 @@ QgsSymbolSelectorWidget::QgsSymbolSelectorWidget( QgsSymbol *symbol, QgsStyle *s
// have been generated using the temporary "downloading" svg. In this case
// we require the preview to be regenerated to use the correct fetched
// svg
mBlockModified = true;
symbolChanged();
updatePreview();
mBlockModified = false;
} );
connect( QgsApplication::imageCache(), &QgsImageCache::remoteImageFetched, this, [ = ]
{
@@ -319,16 +321,20 @@ QgsSymbolSelectorWidget::QgsSymbolSelectorWidget( QgsSymbol *symbol, QgsStyle *s
// have been generated using the temporary "downloading" image. In this case
// we require the preview to be regenerated to use the correct fetched
// image
mBlockModified = true;
symbolChanged();
updatePreview();
mBlockModified = false;
} );

connect( QgsProject::instance(), &QgsProject::projectColorsChanged, this, [ = ]
{
// if project color scheme changes, we need to redraw symbols - they may use project colors and accordingly
// need updating to reflect the new colors
mBlockModified = true;
symbolChanged();
updatePreview();
mBlockModified = false;
} );
}

@@ -436,7 +442,8 @@ void QgsSymbolSelectorWidget::updatePreview()
QImage preview = mSymbol->bigSymbolPreviewImage( &mPreviewExpressionContext );
lblPreview->setPixmap( QPixmap::fromImage( preview ) );
// Hope this is a appropriate place
emit symbolModified();
if ( !mBlockModified )
emit symbolModified();
}

void QgsSymbolSelectorWidget::updateLayerPreview()
@@ -254,6 +254,7 @@ class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::Qgs
QgsSymbolWidgetContext mContext;
QgsFeature mPreviewFeature;
QgsExpressionContext mPreviewExpressionContext;
bool mBlockModified = false;

};

0 comments on commit 394e5d8

Please sign in to comment.
You can’t perform that action at this time.