(#542) Fixed several project-open crashes related to missing files.

Added errormessage on missing wellpath file
This commit is contained in:
Jacob Støren 2015-10-12 12:40:10 +02:00
parent 6b8e51ca87
commit 36d2bb224c
5 changed files with 60 additions and 25 deletions

View File

@ -454,15 +454,21 @@ QString RimWellLogExtractionCurve::createCurveName()
if (eclipseCase)
{
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel());
maxTimeStep = eclipseCase->reservoirData()->results(porosityModel)->maxTimeStepCount();
if(eclipseCase->reservoirData())
{
maxTimeStep = eclipseCase->reservoirData()->results(porosityModel)->maxTimeStepCount();
timeStepNames = eclipseCase->timeStepStrings();
}
timeStepNames = eclipseCase->timeStepStrings();
}
else if (geomCase)
{
maxTimeStep = geomCase->geoMechData()->femPartResults()->frameCount();
if (geomCase->geoMechData())
{
maxTimeStep = geomCase->geoMechData()->femPartResults()->frameCount();
timeStepNames = geomCase->timeStepStrings();
}
timeStepNames = geomCase->timeStepStrings();
}
if (m_addDateToCurveName && m_timeStep < timeStepNames.size())

View File

@ -77,17 +77,19 @@ void RimWellLogFileCurve::updatePlotData()
if (logFileInfo)
{
RigWellLogFile* wellLogFile = logFileInfo->wellLogFile();
std::vector<double> values = wellLogFile->values(m_wellLogChannnelName);
std::vector<double> depthValues = wellLogFile->depthValues();
if (values.size() > 0 && depthValues.size() > 0)
if (wellLogFile)
{
m_plotCurve->setSamples(values.data(), depthValues.data(), (int)depthValues.size());
}
else
{
m_plotCurve->setSamples(NULL, NULL, 0);
std::vector<double> values = wellLogFile->values(m_wellLogChannnelName);
std::vector<double> depthValues = wellLogFile->depthValues();
if (values.size() > 0 && depthValues.size() > 0)
{
m_plotCurve->setSamples(values.data(), depthValues.data(), (int)depthValues.size());
}
else
{
m_plotCurve->setSamples(NULL, NULL, 0);
}
}
if (m_autoName)

View File

@ -158,21 +158,31 @@ caf::PdmFieldHandle* RimWellPath::objectToggleField()
//--------------------------------------------------------------------------------------------------
/// Read JSON file containing well path data
/// Read JSON or ascii file containing well path data
//--------------------------------------------------------------------------------------------------
void RimWellPath::readWellPathFile()
bool RimWellPath::readWellPathFile(QString* errorMessage)
{
QFileInfo fi(filepath());
QFileInfo fileInf(filepath());
if (fi.suffix().compare("json") == 0)
if (fileInf.isFile() && fileInf.exists())
{
this->readJsonWellPathFile();
if (fileInf.suffix().compare("json") == 0)
{
this->readJsonWellPathFile();
}
else
{
this->readAsciiWellPathFile();
}
return true;
}
else
{
this->readAsciiWellPathFile();
}
if (errorMessage) (*errorMessage) = "Could not find the well path file: " + filepath();
return false;
}
}
//--------------------------------------------------------------------------------------------------
@ -273,12 +283,18 @@ QString RimWellPath::getCacheDirectoryPath()
//--------------------------------------------------------------------------------------------------
QString RimWellPath::getCacheFileName()
{
if (filepath().isEmpty())
{
return "";
}
QString cacheFileName;
// Make the path correct related to the possibly new project filename
QString newCacheDirPath = getCacheDirectoryPath();
QFileInfo oldCacheFile(filepath);
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
return cacheFileName;
@ -295,6 +311,11 @@ void RimWellPath::setupBeforeSave()
return;
}
if (filepath().isEmpty())
{
return;
}
QDir::root().mkpath(getCacheDirectoryPath());
QString newCacheFileName = getCacheFileName();

View File

@ -73,7 +73,7 @@ public:
RigWellPath* wellPathGeometry() { return m_wellPath.p(); }
RivWellPathPartMgr* partMgr();
void readWellPathFile();
bool readWellPathFile(QString * errorMessage);
void updateFilePathsFromProjectPath();

View File

@ -132,7 +132,13 @@ void RimWellPathCollection::readWellPathFiles()
{
if (!wellPaths[wpIdx]->filepath().isEmpty())
{
wellPaths[wpIdx]->readWellPathFile();
QString errorMessage;
if (!wellPaths[wpIdx]->readWellPathFile(&errorMessage))
{
QMessageBox::warning(RiuMainWindow::instance(),
"File open error",
errorMessage);
}
}
RimWellLogFile* wellLogFile = wellPaths[wpIdx]->m_wellLogFile;
@ -231,7 +237,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector<RimWellPath*>& wellP
for (size_t wpIdx = 0; wpIdx < wellPathArray.size(); wpIdx++)
{
RimWellPath* wellPath = wellPathArray[wpIdx];
wellPath->readWellPathFile();
wellPath->readWellPathFile(NULL);
progress.setProgressDescription(QString("Reading file %1").arg(wellPath->name));
@ -241,7 +247,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector<RimWellPath*>& wellP
{
existingWellPath->filepath = wellPath->filepath;
existingWellPath->wellPathIndexInFile = wellPath->wellPathIndexInFile;
existingWellPath->readWellPathFile();
existingWellPath->readWellPathFile(NULL);
delete wellPath;
}