Skip to content
Permalink
Browse files

Handle the situation that the project was changed in meanwhile

Was working for files, now working for projects in postgres as well
  • Loading branch information
wonder-sk committed Apr 7, 2018
1 parent 2bbdc34 commit 4281140c8e9ca2417f17c21d5c56fa197662c173
Showing with 10 additions and 10 deletions.
  1. +10 −10 src/app/qgisapp.cpp
@@ -5591,7 +5591,7 @@ bool QgisApp::addProject( const QString &projectFile )
// We loaded data from the backup file, but we pretend to work on the original project file.
QgsProject::instance()->setFileName( projectFile );
QgsProject::instance()->setDirty( true );
mProjectLastModified = pfi.lastModified();
mProjectLastModified = QgsProject::instance()->lastModified();
return true;
}

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

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

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

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

QFileInfo fullPath;
fullPath.setFile( path );

// make sure we have the .qgs extension in the file name
@@ -5738,22 +5738,23 @@ bool QgisApp::fileSave()
}
else
{
QFileInfo fi( QgsProject::instance()->fileName() );
fullPath = fi.absoluteFilePath();
if ( fi.exists() && !mProjectLastModified.isNull() && mProjectLastModified != fi.lastModified() )
bool usingProjectStorage = QgsApplication::projectStorageRegistry()->projectStorageFromUri( QgsProject::instance()->fileName() );
bool fileExists = usingProjectStorage ? true : QFileInfo( QgsProject::instance()->fileName() ).exists();

if ( fileExists && !mProjectLastModified.isNull() && mProjectLastModified != QgsProject::instance()->lastModified() )
{
if ( QMessageBox::warning( this,
tr( "Open a Project" ),
tr( "The loaded project file on disk was meanwhile changed. Do you want to overwrite the changes?\n"
"\nLast modification date on load was: %1"
"\nCurrent last modification date is: %2" )
.arg( mProjectLastModified.toString( Qt::DefaultLocaleLongDate ),
fi.lastModified().toString( Qt::DefaultLocaleLongDate ) ),
QgsProject::instance()->lastModified().toString( Qt::DefaultLocaleLongDate ) ),
QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
return false;
}

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

saveRecentProjectPath();

QFileInfo fi( QgsProject::instance()->fileName() );
mProjectLastModified = fi.lastModified();
mProjectLastModified = QgsProject::instance()->lastModified();
}
else
{

0 comments on commit 4281140

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