#4538 Skip Save project at exit when no data has changed

Guard changes in preferences and reset change detector when project is closed
This commit is contained in:
Magne Sjaastad 2019-08-07 14:21:37 +02:00
parent 5e2485863c
commit 58cef265ec
5 changed files with 26 additions and 6 deletions

View File

@ -84,6 +84,7 @@
#include "RimWellRftPlot.h"
#include "cafPdmSettings.h"
#include "cafPdmUiModelChangeDetector.h"
#include "cafProgressInfo.h"
#include "cafUiProcess.h"
#include "cafUtils.h"
@ -305,6 +306,16 @@ bool RiaApplication::openFile(const QString& fileName)
return loadingSucceded;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication::isProjectSavedToDisc() const
{
if (m_project.isNull()) return false;
return caf::Utils::fileExists(m_project->fileName());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -370,7 +381,7 @@ bool RiaApplication::loadProject(const QString& projectFileName,
// Create a absolute path file name, as this is required for update of file references in the project modifier object
QString fullPathProjectFileName = caf::Utils::absoluteFileName(projectFileName);
if (!caf::Utils::fileExists(fullPathProjectFileName))
if (!isProjectSavedToDisc())
{
RiaLogging::info(QString("File does not exist : '%1'").arg(fullPathProjectFileName));
return false;
@ -677,6 +688,8 @@ void RiaApplication::closeProject()
m_commandQueue.clear();
onProjectClosed();
caf::PdmUiModelChangeDetector::instance()->reset();
}
//--------------------------------------------------------------------------------------------------

View File

@ -121,6 +121,7 @@ public:
bool openFile(const QString& fileName);
bool isProjectSavedToDisc() const;
QString currentProjectPath() const;
QString createAbsolutePathFromProjectRelativePath(QString projectRelativePath);
bool loadProject(const QString& projectFileName);

View File

@ -204,7 +204,7 @@ bool RiaGuiApplication::saveProject()
{
CVF_ASSERT(m_project.notNull());
if (!caf::Utils::fileExists(m_project->fileName()))
if (!isProjectSavedToDisc())
{
return saveProjectPromptForFileName();
}

View File

@ -24,6 +24,7 @@
#include "RiuPropertyViewTabWidget.h"
#include "cafPdmSettings.h"
#include "cafPdmUiModelChangeDetector.h"
#include <QAction>
@ -65,6 +66,13 @@ void RicEditPreferencesFeature::onActionTriggered(bool isChecked)
caf::PdmSettings::readFieldsFromApplicationStore(app->preferences());
app->preferences()->initAfterReadRecursively();
}
if (!app->isProjectSavedToDisc())
{
// Always reset change detector when modifying preferences, as these changes are irrelevant
// when the project we work on is not saved to disc
caf::PdmUiModelChangeDetector::instance()->reset();
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -27,8 +27,6 @@
#include "RiuMainWindow.h"
#include "RiuWellImportWizard.h"
#include "cafUtils.h"
#include <QAction>
#include <QDir>
#include <QFile>
@ -52,7 +50,7 @@ void RicWellPathsImportSsihubFeature::onActionTriggered(bool isChecked)
RiaApplication* app = RiaApplication::instance();
if (!app->project()) return;
if (!caf::Utils::fileExists(app->project()->fileName()))
if (!app->isProjectSavedToDisc())
{
RiaGuiApplication* guiApp = RiaGuiApplication::instance();
if (guiApp)
@ -74,7 +72,7 @@ void RicWellPathsImportSsihubFeature::onActionTriggered(bool isChecked)
}
}
if (!caf::Utils::fileExists(app->project()->fileName()))
if (!app->isProjectSavedToDisc())
{
return;
}