#13963 Well path: Migrate legacy SSIHUB cache file path to m_filePath

Restore m_filePathInCache_OBSOLETE as a read-only field (write disabled)
so existing projects that stored the well path in WellPathFilePathInCache
can still be loaded. In initAfterRead, look up the cache file in the
current project's cache directory and copy the path into m_filePath.
This commit is contained in:
Magne Sjaastad committed 2026-05-07 12:57:05 +02:00
1 parent 8638e5a14c
commit 0e27709fe3
2 files changed
+29

No files matched your search

@@ -5,9 +5,12 @@
#include "RifWellPathImporter.h"
#include "RimProject.h"
#include "RimTools.h"
#include "cafUtils.h"
#include <QFileInfo>
CAF_PDM_SOURCE_INIT( RimFileWellPath, "WellPath" );
//--------------------------------------------------------------------------------------------------
@@ -39,6 +42,12 @@ RimFileWellPath::RimFileWellPath()
CAF_PDM_InitFieldNoDefault( &m_filePath, "WellPathFilepath", "File Path" );
m_filePath.uiCapability()->setUiReadOnly( true );
// Read-only legacy field used to migrate SSIHUB-cached well paths saved before commit
// bdb46d9df407878f0016ea2c150f44cc07fef698 removed the cache mechanism. See initAfterRead.
CAF_PDM_InitFieldNoDefault( &m_filePathInCache_OBSOLETE, "WellPathFilePathInCache", "File Name" );
m_filePathInCache_OBSOLETE.uiCapability()->setUiHidden( true );
m_filePathInCache_OBSOLETE.xmlCapability()->setIOWritable( false );
CAF_PDM_InitField( &m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File" );
m_wellPathIndexInFile.uiCapability()->setUiReadOnly( true );
@@ -215,3 +224,21 @@ void RimFileWellPath::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFileWellPath::initAfterRead()
{
RimWellPath::initAfterRead();
QString cachedPath = m_filePathInCache_OBSOLETE().path();
if ( cachedPath.isEmpty() ) return;
QString newCacheFileName = RimTools::getCacheRootDirectoryPathFromProject() + "_wellpaths/" + QFileInfo( cachedPath ).fileName();
if ( caf::Utils::fileExists( newCacheFileName ) )
{
m_filePath = newCacheFileName;
}
}