#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 )
{
loadingSucceded = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{fileName}, true );
loadingSucceded = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{ fileName }, true );
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
//--------------------------------------------------------------------------------------------------
std::vector<RimFileWellPath*> RiaApplication::addWellPathsToModel( QList<QString> wellPathFilePaths,
QStringList* errorMessages )
std::vector<RimWellPath*> RiaApplication::addWellPathsToModel( QList<QString> wellPathFilePaths,
QStringList* errorMessages )
{
CAF_ASSERT( errorMessages );
@ -867,7 +867,7 @@ std::vector<RimFileWellPath*> RiaApplication::addWellPathsToModel( QList<QString
m_project->updateConnectedEditors();
}
std::vector<RimFileWellPath*> wellPaths;
std::vector<RimWellPath*> wellPaths;
if ( oilField->wellPathCollection )
{
wellPaths = oilField->wellPathCollection->addWellPaths( wellPathFilePaths, errorMessages );

View File

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

View File

@ -103,11 +103,11 @@ RicfCommandResponse RicImportWellPaths::execute()
RicfCommandResponse response;
if ( !wellPathFiles.empty() )
{
std::vector<RimFileWellPath*> importedWellPaths = importWellPaths( wellPathFiles, &warningMessages );
std::vector<RimWellPath*> importedWellPaths = importWellPaths( wellPathFiles, &warningMessages );
if ( !importedWellPaths.empty() )
{
RicImportWellPathsResult* wellPathsResult = new RicImportWellPathsResult;
for ( RimFileWellPath* wellPath : importedWellPaths )
for ( RimWellPath* wellPath : importedWellPaths )
{
wellPathsResult->wellPathNames.v().push_back( wellPath->name() );
}
@ -136,15 +136,15 @@ RicfCommandResponse RicImportWellPaths::execute()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimFileWellPath*> RicImportWellPaths::importWellPaths( const QStringList& wellPathFilePaths,
QStringList* errorMessages )
std::vector<RimWellPath*> RicImportWellPaths::importWellPaths( const QStringList& wellPathFilePaths,
QStringList* errorMessages )
{
RiaApplication* app = RiaApplication::instance();
// Remember the path to next time
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();

View File

@ -29,7 +29,7 @@
#include <vector>
class RimFileWellPath;
class RimWellPath;
//==================================================================================================
///
@ -43,9 +43,8 @@ public:
RicfCommandResponse execute() override;
protected:
static std::vector<RimFileWellPath*> importWellPaths( const QStringList& wellPathFilePaths,
QStringList* errorMessages );
static QStringList wellPathNameFilters();
static std::vector<RimWellPath*> importWellPaths( const QStringList& wellPathFilePaths, QStringList* errorMessages );
static QStringList wellPathNameFilters();
// Overrides
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 );
@ -259,11 +259,12 @@ std::vector<RimFileWellPath*> RimWellPathCollection::addWellPaths( QStringList f
}
readAndAddWellPaths( wellPathArray );
CAF_ASSERT( wellPathArray.empty() );
scheduleRedrawAffectedViews();
updateAllRequiredEditors();
return wellPathArray;
return wellPaths.childObjects();
}
//--------------------------------------------------------------------------------------------------
@ -304,7 +305,7 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector<RimFileWellPath*>&
progress.incrementProgress();
}
wellPathArray.clear(); // This should not be used again. We may have deleted items
this->sortWellsByName();
}

View File

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