Skip to content

Commit a525b2d

Browse files
authored
Mark project as dirty when changing layer subset string
1 parent e25c813 commit a525b2d

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/gui/qgsquerybuilder.cpp

+19-14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
***************************************************************************/
1515
#include "qgsquerybuilder.h"
1616
#include "qgslogger.h"
17+
#include "qgsproject.h"
1718
#include "qgssettings.h"
1819
#include "qgsvectorlayer.h"
1920
#include "qgsvectordataprovider.h"
@@ -243,23 +244,27 @@ void QgsQueryBuilder::test()
243244

244245
void QgsQueryBuilder::accept()
245246
{
246-
if ( !mLayer->setSubsetString( txtSQL->text() ) )
247+
if ( txtSQL->text() != mOrigSubsetString )
247248
{
248-
//error in query - show the problem
249-
if ( mLayer->dataProvider()->hasErrors() )
249+
if ( !mLayer->setSubsetString( txtSQL->text() ) )
250250
{
251-
QMessageBox::warning( this,
252-
tr( "Query Result" ),
253-
tr( "An error occurred when executing the query." )
254-
+ tr( "\nThe data provider said:\n%1" ).arg( mLayer->dataProvider()->errors().join( QStringLiteral( "\n" ) ) ) );
255-
mLayer->dataProvider()->clearErrors();
256-
}
257-
else
258-
{
259-
QMessageBox::warning( this, tr( "Query Result" ), tr( "Error in query. The subset string could not be set." ) );
251+
//error in query - show the problem
252+
if ( mLayer->dataProvider()->hasErrors() )
253+
{
254+
QMessageBox::warning( this,
255+
tr( "Query Result" ),
256+
tr( "An error occurred when executing the query." )
257+
+ tr( "\nThe data provider said:\n%1" ).arg( mLayer->dataProvider()->errors().join( QStringLiteral( "\n" ) ) ) );
258+
mLayer->dataProvider()->clearErrors();
259+
}
260+
else
261+
{
262+
QMessageBox::warning( this, tr( "Query Result" ), tr( "Error in query. The subset string could not be set." ) );
263+
}
264+
265+
return;
260266
}
261-
262-
return;
267+
QgsProject::instance()->setDirty( true );
263268
}
264269

265270
QDialog::accept();

0 commit comments

Comments
 (0)