Skip to content

Commit 4281140

Browse files
committed
Handle the situation that the project was changed in meanwhile
Was working for files, now working for projects in postgres as well
1 parent 2bbdc34 commit 4281140

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/app/qgisapp.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5591,7 +5591,7 @@ bool QgisApp::addProject( const QString &projectFile )
55915591
// We loaded data from the backup file, but we pretend to work on the original project file.
55925592
QgsProject::instance()->setFileName( projectFile );
55935593
QgsProject::instance()->setDirty( true );
5594-
mProjectLastModified = pfi.lastModified();
5594+
mProjectLastModified = QgsProject::instance()->lastModified();
55955595
return true;
55965596
}
55975597

@@ -5600,7 +5600,7 @@ bool QgisApp::addProject( const QString &projectFile )
56005600
return false;
56015601
}
56025602

5603-
mProjectLastModified = pfi.lastModified();
5603+
mProjectLastModified = QgsProject::instance()->lastModified();
56045604

56055605
setTitleBarText_( *this );
56065606
int myRedInt = QgsProject::instance()->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorRedPart" ), 255 );
@@ -5701,7 +5701,6 @@ bool QgisApp::fileSave()
57015701
{
57025702
// if we don't have a file name, then obviously we need to get one; note
57035703
// that the project file name is reset to null in fileNew()
5704-
QFileInfo fullPath;
57055704

57065705
if ( QgsProject::instance()->fileName().isNull() )
57075706
{
@@ -5720,6 +5719,7 @@ bool QgisApp::fileSave()
57205719
if ( path.isEmpty() )
57215720
return false;
57225721

5722+
QFileInfo fullPath;
57235723
fullPath.setFile( path );
57245724

57255725
// make sure we have the .qgs extension in the file name
@@ -5738,22 +5738,23 @@ bool QgisApp::fileSave()
57385738
}
57395739
else
57405740
{
5741-
QFileInfo fi( QgsProject::instance()->fileName() );
5742-
fullPath = fi.absoluteFilePath();
5743-
if ( fi.exists() && !mProjectLastModified.isNull() && mProjectLastModified != fi.lastModified() )
5741+
bool usingProjectStorage = QgsApplication::projectStorageRegistry()->projectStorageFromUri( QgsProject::instance()->fileName() );
5742+
bool fileExists = usingProjectStorage ? true : QFileInfo( QgsProject::instance()->fileName() ).exists();
5743+
5744+
if ( fileExists && !mProjectLastModified.isNull() && mProjectLastModified != QgsProject::instance()->lastModified() )
57445745
{
57455746
if ( QMessageBox::warning( this,
57465747
tr( "Open a Project" ),
57475748
tr( "The loaded project file on disk was meanwhile changed. Do you want to overwrite the changes?\n"
57485749
"\nLast modification date on load was: %1"
57495750
"\nCurrent last modification date is: %2" )
57505751
.arg( mProjectLastModified.toString( Qt::DefaultLocaleLongDate ),
5751-
fi.lastModified().toString( Qt::DefaultLocaleLongDate ) ),
5752+
QgsProject::instance()->lastModified().toString( Qt::DefaultLocaleLongDate ) ),
57525753
QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
57535754
return false;
57545755
}
57555756

5756-
if ( fi.exists() && ! fi.isWritable() )
5757+
if ( fileExists && !usingProjectStorage && ! QFileInfo( QgsProject::instance()->fileName() ).isWritable() )
57575758
{
57585759
messageBar()->pushMessage( tr( "Insufficient permissions" ),
57595760
tr( "The project file is not writable." ),
@@ -5769,8 +5770,7 @@ bool QgisApp::fileSave()
57695770

57705771
saveRecentProjectPath();
57715772

5772-
QFileInfo fi( QgsProject::instance()->fileName() );
5773-
mProjectLastModified = fi.lastModified();
5773+
mProjectLastModified = QgsProject::instance()->lastModified();
57745774
}
57755775
else
57765776
{

0 commit comments

Comments
 (0)