(#537) Showing error message box if opening a LAS file fails

This commit is contained in:
Pål Hagen 2015-09-24 09:37:26 +02:00
parent 71e74599ff
commit 5d18209e26
4 changed files with 28 additions and 4 deletions

View File

@ -82,13 +82,15 @@ bool RimWellLogFile::readFile()
m_wellLogDataFile = new RigWellLogFile;
}
m_name = QFileInfo(m_fileName).fileName();
if (!m_wellLogDataFile->open(m_fileName))
{
m_wellLogDataFile = NULL;
return false;
}
m_wellName = m_wellLogDataFile->wellName();
m_name = QFileInfo(m_fileName).fileName();
m_wellLogChannelNames.deleteAllChildObjects();

View File

@ -43,7 +43,9 @@ public:
RimWellLogFile();
virtual ~RimWellLogFile();
void setFileName(const QString& fileName);
void setFileName(const QString& fileName);
QString fileName() const { return m_fileName; }
bool readFile();
QString wellName() const;

View File

@ -27,8 +27,11 @@
#include "RimWellPathCollection.h"
#include "RivWellPathPartMgr.h"
#include "RiuMainWindow.h"
#include <QDir>
#include <QFileInfo>
#include <QMessageBox>
CAF_PDM_SOURCE_INIT(RimWellPath, "WellPath");
@ -187,6 +190,12 @@ RimWellLogFile* RimWellPath::readWellLogFile(const QString& logFilePath)
wellLogFile->setFileName(logFilePath);
if (!wellLogFile->readFile())
{
QString errorMessage = "Could not open the LAS file: \n" + logFilePath;
QMessageBox::warning(RiuMainWindow::instance(),
"File open error",
errorMessage);
delete wellLogFile;
wellLogFile = NULL;
}

View File

@ -27,11 +27,14 @@
#include "RimWellLogFile.h"
#include "RivWellPathCollectionPartMgr.h"
#include "RiuMainWindow.h"
#include "cafPdmUiEditorHandle.h"
#include "cafProgressInfo.h"
#include <QFile>
#include <QFileInfo>
#include <QMessageBox>
#include <fstream>
#include <cmath>
@ -132,9 +135,17 @@ void RimWellPathCollection::readWellPathFiles()
wellPaths[wpIdx]->readWellPathFile();
}
if (wellPaths[wpIdx]->m_wellLogFile)
RimWellLogFile* wellLogFile = wellPaths[wpIdx]->m_wellLogFile;
if (wellLogFile)
{
wellPaths[wpIdx]->m_wellLogFile->readFile();
if (!wellLogFile->readFile())
{
QString errorMessage = "Could not open the well log file: \n" + wellLogFile->fileName();
QMessageBox::warning(RiuMainWindow::instance(),
"File open error",
errorMessage);
}
}
progress.setProgressDescription(QString("Reading file %1").arg(wellPaths[wpIdx]->name));