Simplify PdmDocument class and move fileName to private

Remove resolveReferencesRecursively() and initAfterReadRecursively() from PdmDocument::readFile(). These functions will be called in RiaApplication::loadProject after the file paths modifications are done. This will ensure that file paths can be used in initAfterRead() functions.
This commit is contained in:
Magne Sjaastad
2024-06-05 11:00:55 +02:00
parent beccd2454e
commit 41d5e498d7
9 changed files with 66 additions and 48 deletions

View File

@@ -283,7 +283,7 @@ void RimProject::close()
delete viewLinkerCollection->viewLinker();
viewLinkerCollection->viewLinker = nullptr;
fileName = "";
setFileName( "" );
m_globalPathList = "";
@@ -303,7 +303,7 @@ void RimProject::close()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::beforeInitAfterRead()
void RimProject::updatesAfterProjectFileIsRead()
{
distributePathsFromGlobalPathList();
@@ -408,7 +408,7 @@ bool RimProject::writeProjectFile()
{
transferPathsToGlobalPathList();
QFile xmlFile( fileName );
QFile xmlFile( fileName() );
if ( !xmlFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false;
QString content = documentAsString();
@@ -416,7 +416,7 @@ bool RimProject::writeProjectFile()
if ( RiaPreferences::current()->storeBackupOfProjectFiles() )
{
QString backupFilename = fileName + "db";
QString backupFilename = fileName() + "db";
const int maximumRecordCount = 50;
RiaProjectBackupTools::appendTextToDatabase( backupFilename, maximumRecordCount, content );
}
@@ -488,9 +488,10 @@ bool RimProject::isProjectFileVersionEqualOrOlderThan( const QString& otherProje
void RimProject::setProjectFileNameAndUpdateDependencies( const QString& projectFileName )
{
// Extract the filename of the project file when it was saved
QString oldProjectFileName = fileName;
QString oldProjectFileName = fileName();
// Replace with the new actual filename
fileName = projectFileName;
setFileName( projectFileName );
QFileInfo fileInfo( projectFileName );
QString newProjectPath = fileInfo.path();

View File

@@ -195,8 +195,9 @@ public:
std::vector<caf::FilePath*> allFilePaths() const;
void updatesAfterProjectFileIsRead();
protected:
void beforeInitAfterRead() override;
void initAfterRead() override;
void setupBeforeSave() override;