Skip to content

Commit

Permalink
Mark project as dirty when changing layer subset string
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed May 28, 2018
1 parent e25c813 commit a525b2d
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/gui/qgsquerybuilder.cpp
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/
#include "qgsquerybuilder.h"
#include "qgslogger.h"
#include "qgsproject.h"
#include "qgssettings.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
Expand Down Expand Up @@ -243,23 +244,27 @@ void QgsQueryBuilder::test()

void QgsQueryBuilder::accept()
{
if ( !mLayer->setSubsetString( txtSQL->text() ) )
if ( txtSQL->text() != mOrigSubsetString )
{
//error in query - show the problem
if ( mLayer->dataProvider()->hasErrors() )
if ( !mLayer->setSubsetString( txtSQL->text() ) )
{
QMessageBox::warning( this,
tr( "Query Result" ),
tr( "An error occurred when executing the query." )
+ tr( "\nThe data provider said:\n%1" ).arg( mLayer->dataProvider()->errors().join( QStringLiteral( "\n" ) ) ) );
mLayer->dataProvider()->clearErrors();
}
else
{
QMessageBox::warning( this, tr( "Query Result" ), tr( "Error in query. The subset string could not be set." ) );
//error in query - show the problem
if ( mLayer->dataProvider()->hasErrors() )
{
QMessageBox::warning( this,
tr( "Query Result" ),
tr( "An error occurred when executing the query." )
+ tr( "\nThe data provider said:\n%1" ).arg( mLayer->dataProvider()->errors().join( QStringLiteral( "\n" ) ) ) );
mLayer->dataProvider()->clearErrors();
}
else
{
QMessageBox::warning( this, tr( "Query Result" ), tr( "Error in query. The subset string could not be set." ) );
}

return;
}

return;
QgsProject::instance()->setDirty( true );
}

QDialog::accept();
Expand Down

0 comments on commit a525b2d

Please sign in to comment.