mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#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:
parent
5e2485863c
commit
58cef265ec
@ -84,6 +84,7 @@
|
|||||||
#include "RimWellRftPlot.h"
|
#include "RimWellRftPlot.h"
|
||||||
|
|
||||||
#include "cafPdmSettings.h"
|
#include "cafPdmSettings.h"
|
||||||
|
#include "cafPdmUiModelChangeDetector.h"
|
||||||
#include "cafProgressInfo.h"
|
#include "cafProgressInfo.h"
|
||||||
#include "cafUiProcess.h"
|
#include "cafUiProcess.h"
|
||||||
#include "cafUtils.h"
|
#include "cafUtils.h"
|
||||||
@ -305,6 +306,16 @@ bool RiaApplication::openFile(const QString& fileName)
|
|||||||
return loadingSucceded;
|
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
|
// 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);
|
QString fullPathProjectFileName = caf::Utils::absoluteFileName(projectFileName);
|
||||||
if (!caf::Utils::fileExists(fullPathProjectFileName))
|
if (!isProjectSavedToDisc())
|
||||||
{
|
{
|
||||||
RiaLogging::info(QString("File does not exist : '%1'").arg(fullPathProjectFileName));
|
RiaLogging::info(QString("File does not exist : '%1'").arg(fullPathProjectFileName));
|
||||||
return false;
|
return false;
|
||||||
@ -677,6 +688,8 @@ void RiaApplication::closeProject()
|
|||||||
m_commandQueue.clear();
|
m_commandQueue.clear();
|
||||||
|
|
||||||
onProjectClosed();
|
onProjectClosed();
|
||||||
|
|
||||||
|
caf::PdmUiModelChangeDetector::instance()->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -121,6 +121,7 @@ public:
|
|||||||
|
|
||||||
bool openFile(const QString& fileName);
|
bool openFile(const QString& fileName);
|
||||||
|
|
||||||
|
bool isProjectSavedToDisc() const;
|
||||||
QString currentProjectPath() const;
|
QString currentProjectPath() const;
|
||||||
QString createAbsolutePathFromProjectRelativePath(QString projectRelativePath);
|
QString createAbsolutePathFromProjectRelativePath(QString projectRelativePath);
|
||||||
bool loadProject(const QString& projectFileName);
|
bool loadProject(const QString& projectFileName);
|
||||||
|
@ -204,7 +204,7 @@ bool RiaGuiApplication::saveProject()
|
|||||||
{
|
{
|
||||||
CVF_ASSERT(m_project.notNull());
|
CVF_ASSERT(m_project.notNull());
|
||||||
|
|
||||||
if (!caf::Utils::fileExists(m_project->fileName()))
|
if (!isProjectSavedToDisc())
|
||||||
{
|
{
|
||||||
return saveProjectPromptForFileName();
|
return saveProjectPromptForFileName();
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "RiuPropertyViewTabWidget.h"
|
#include "RiuPropertyViewTabWidget.h"
|
||||||
|
|
||||||
#include "cafPdmSettings.h"
|
#include "cafPdmSettings.h"
|
||||||
|
#include "cafPdmUiModelChangeDetector.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
@ -65,6 +66,13 @@ void RicEditPreferencesFeature::onActionTriggered(bool isChecked)
|
|||||||
caf::PdmSettings::readFieldsFromApplicationStore(app->preferences());
|
caf::PdmSettings::readFieldsFromApplicationStore(app->preferences());
|
||||||
app->preferences()->initAfterReadRecursively();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#include "RiuMainWindow.h"
|
#include "RiuMainWindow.h"
|
||||||
#include "RiuWellImportWizard.h"
|
#include "RiuWellImportWizard.h"
|
||||||
|
|
||||||
#include "cafUtils.h"
|
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -52,7 +50,7 @@ void RicWellPathsImportSsihubFeature::onActionTriggered(bool isChecked)
|
|||||||
RiaApplication* app = RiaApplication::instance();
|
RiaApplication* app = RiaApplication::instance();
|
||||||
if (!app->project()) return;
|
if (!app->project()) return;
|
||||||
|
|
||||||
if (!caf::Utils::fileExists(app->project()->fileName()))
|
if (!app->isProjectSavedToDisc())
|
||||||
{
|
{
|
||||||
RiaGuiApplication* guiApp = RiaGuiApplication::instance();
|
RiaGuiApplication* guiApp = RiaGuiApplication::instance();
|
||||||
if (guiApp)
|
if (guiApp)
|
||||||
@ -74,7 +72,7 @@ void RicWellPathsImportSsihubFeature::onActionTriggered(bool isChecked)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!caf::Utils::fileExists(app->project()->fileName()))
|
if (!app->isProjectSavedToDisc())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user