#5106 Fix crash when importing multiple well paths with the same name

This commit is contained in:
Gaute Lindkvist 2019-11-30 10:23:24 +01:00
parent c5f21b75fa
commit 538e42f278
6 changed files with 21 additions and 21 deletions

View File

@ -316,7 +316,7 @@ bool RiaApplication::openFile( const QString& fileName )
} }
else if ( fileType & RiaDefines::ANY_ECLIPSE_FILE ) else if ( fileType & RiaDefines::ANY_ECLIPSE_FILE )
{ {
loadingSucceded = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{fileName}, true ); loadingSucceded = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{ fileName }, true );
lastUsedDialogTag = RiaDefines::defaultDirectoryLabel( fileType ); lastUsedDialogTag = RiaDefines::defaultDirectoryLabel( fileType );
} }
@ -849,8 +849,8 @@ bool RiaApplication::openOdbCaseFromFile( const QString& fileName, bool applyTim
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Add a list of well path file paths (JSON files) to the well path collection /// Add a list of well path file paths (JSON files) to the well path collection
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RimFileWellPath*> RiaApplication::addWellPathsToModel( QList<QString> wellPathFilePaths, std::vector<RimWellPath*> RiaApplication::addWellPathsToModel( QList<QString> wellPathFilePaths,
QStringList* errorMessages ) QStringList* errorMessages )
{ {
CAF_ASSERT( errorMessages ); CAF_ASSERT( errorMessages );
@ -867,7 +867,7 @@ std::vector<RimFileWellPath*> RiaApplication::addWellPathsToModel( QList<QString
m_project->updateConnectedEditors(); m_project->updateConnectedEditors();
} }
std::vector<RimFileWellPath*> wellPaths; std::vector<RimWellPath*> wellPaths;
if ( oilField->wellPathCollection ) if ( oilField->wellPathCollection )
{ {
wellPaths = oilField->wellPathCollection->addWellPaths( wellPathFilePaths, errorMessages ); wellPaths = oilField->wellPathCollection->addWellPaths( wellPathFilePaths, errorMessages );

View File

@ -54,7 +54,7 @@ class RigEclipseCaseData;
class RimCommandObject; class RimCommandObject;
class RimEclipseCase; class RimEclipseCase;
class RimEclipseView; class RimEclipseView;
class RimFileWellPath; class RimWellPath;
class RimGridView; class RimGridView;
class RimProject; class RimProject;
class RimSummaryPlot; class RimSummaryPlot;
@ -144,8 +144,8 @@ public:
bool openOdbCaseFromFile( const QString& fileName, bool applyTimeStepFilter = false ); bool openOdbCaseFromFile( const QString& fileName, bool applyTimeStepFilter = false );
std::vector<RimFileWellPath*> addWellPathsToModel( QList<QString> wellPathFilePaths, QStringList* errorMessages ); std::vector<RimWellPath*> addWellPathsToModel( QList<QString> wellPathFilePaths, QStringList* errorMessages );
void addWellPathFormationsToModel( QList<QString> wellPathFilePaths ); void addWellPathFormationsToModel( QList<QString> wellPathFilePaths );
std::vector<RimWellLogFile*> addWellLogsToModel( const QList<QString>& wellLogFilePaths, QStringList* errorMessages ); std::vector<RimWellLogFile*> addWellLogsToModel( const QList<QString>& wellLogFilePaths, QStringList* errorMessages );
QString scriptDirectories() const; QString scriptDirectories() const;

View File

@ -103,11 +103,11 @@ RicfCommandResponse RicImportWellPaths::execute()
RicfCommandResponse response; RicfCommandResponse response;
if ( !wellPathFiles.empty() ) if ( !wellPathFiles.empty() )
{ {
std::vector<RimFileWellPath*> importedWellPaths = importWellPaths( wellPathFiles, &warningMessages ); std::vector<RimWellPath*> importedWellPaths = importWellPaths( wellPathFiles, &warningMessages );
if ( !importedWellPaths.empty() ) if ( !importedWellPaths.empty() )
{ {
RicImportWellPathsResult* wellPathsResult = new RicImportWellPathsResult; RicImportWellPathsResult* wellPathsResult = new RicImportWellPathsResult;
for ( RimFileWellPath* wellPath : importedWellPaths ) for ( RimWellPath* wellPath : importedWellPaths )
{ {
wellPathsResult->wellPathNames.v().push_back( wellPath->name() ); wellPathsResult->wellPathNames.v().push_back( wellPath->name() );
} }
@ -136,15 +136,15 @@ RicfCommandResponse RicImportWellPaths::execute()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RimFileWellPath*> RicImportWellPaths::importWellPaths( const QStringList& wellPathFilePaths, std::vector<RimWellPath*> RicImportWellPaths::importWellPaths( const QStringList& wellPathFilePaths,
QStringList* errorMessages ) QStringList* errorMessages )
{ {
RiaApplication* app = RiaApplication::instance(); RiaApplication* app = RiaApplication::instance();
// Remember the path to next time // Remember the path to next time
app->setLastUsedDialogDirectory( "WELLPATH_DIR", QFileInfo( wellPathFilePaths.last() ).absolutePath() ); app->setLastUsedDialogDirectory( "WELLPATH_DIR", QFileInfo( wellPathFilePaths.last() ).absolutePath() );
std::vector<RimFileWellPath*> wellPaths = app->addWellPathsToModel( wellPathFilePaths, errorMessages ); std::vector<RimWellPath*> wellPaths = app->addWellPathsToModel( wellPathFilePaths, errorMessages );
RimProject* project = app->project(); RimProject* project = app->project();

View File

@ -29,7 +29,7 @@
#include <vector> #include <vector>
class RimFileWellPath; class RimWellPath;
//================================================================================================== //==================================================================================================
/// ///
@ -43,9 +43,8 @@ public:
RicfCommandResponse execute() override; RicfCommandResponse execute() override;
protected: protected:
static std::vector<RimFileWellPath*> importWellPaths( const QStringList& wellPathFilePaths, static std::vector<RimWellPath*> importWellPaths( const QStringList& wellPathFilePaths, QStringList* errorMessages );
QStringList* errorMessages ); static QStringList wellPathNameFilters();
static QStringList wellPathNameFilters();
// Overrides // Overrides
bool isCommandEnabled() override; bool isCommandEnabled() override;

View File

@ -202,7 +202,7 @@ void RimWellPathCollection::loadDataAndUpdate()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RimFileWellPath*> RimWellPathCollection::addWellPaths( QStringList filePaths, QStringList* errorMessages ) std::vector<RimWellPath*> RimWellPathCollection::addWellPaths( QStringList filePaths, QStringList* errorMessages )
{ {
CAF_ASSERT( errorMessages ); CAF_ASSERT( errorMessages );
@ -259,11 +259,12 @@ std::vector<RimFileWellPath*> RimWellPathCollection::addWellPaths( QStringList f
} }
readAndAddWellPaths( wellPathArray ); readAndAddWellPaths( wellPathArray );
CAF_ASSERT( wellPathArray.empty() );
scheduleRedrawAffectedViews(); scheduleRedrawAffectedViews();
updateAllRequiredEditors(); updateAllRequiredEditors();
return wellPathArray; return wellPaths.childObjects();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -304,7 +305,7 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector<RimFileWellPath*>&
progress.incrementProgress(); progress.incrementProgress();
} }
wellPathArray.clear(); // This should not be used again. We may have deleted items
this->sortWellsByName(); this->sortWellsByName();
} }

View File

@ -89,8 +89,8 @@ public:
caf::PdmChildArrayField<RimWellPath*> wellPaths; caf::PdmChildArrayField<RimWellPath*> wellPaths;
void loadDataAndUpdate(); void loadDataAndUpdate();
std::vector<RimFileWellPath*> addWellPaths( QStringList filePaths, QStringList* errorMessages ); std::vector<RimWellPath*> addWellPaths( QStringList filePaths, QStringList* errorMessages );
void removeWellPath( RimWellPath* wellPath ); void removeWellPath( RimWellPath* wellPath );
void deleteAllWellPaths(); void deleteAllWellPaths();