#4509 Guard access to gui application code in import and well path code to avoid crashes in console mode

This commit is contained in:
Gaute Lindkvist
2019-07-25 15:54:20 +02:00
parent d6d1ebd25d
commit 000ce6db52
8 changed files with 113 additions and 47 deletions

View File

@@ -180,10 +180,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file
project->activeOilField()->completionTemplateCollection()->setDefaultUnitSystemBasedOnLoadedCases();
if (RiaGuiApplication::isRunning())
{
RiuPlotMainWindowTools::refreshToolbars();
}
if (openedFilesOut)
{

View File

@@ -18,6 +18,7 @@
#include "RifWellPathFormationReader.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "Riu3DMainWindowTools.h"
@@ -62,17 +63,23 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
}
if (wellNames.empty() || formationNames.empty())
{
if (RiaGuiApplication::isRunning())
{
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Import failure",
QString("Failed to parse %1 as a well pick file").arg(filePath));
}
RiaLogging::error(QString("Failed to parse %1 as a well pick file").arg(filePath));
return result;
}
else if (!(mdIsPresent || tvdIsPresent))
{
if (RiaGuiApplication::isRunning())
{
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Import failure",
QString("Failed to parse %1 as a well pick file. Neither MD or TVD is present.").arg(filePath));
}
RiaLogging::error(QString("Failed to parse %1 as a well pick file. Neither MD or TVD is present.").arg(filePath));
return result;

View File

@@ -142,10 +142,14 @@ void RimGeoMechView::onLoadDataAndUpdate()
{
QString displayMessage = errorMessage.empty() ? "Could not open the Odb file: \n" + m_geomechCase->caseFileName() : QString::fromStdString(errorMessage);
if (RiaGuiApplication::isRunning())
{
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(),
"File open error",
displayMessage);
}
RiaLogging::error(displayMessage);
}
m_geomechCase = nullptr;
return;

View File

@@ -20,6 +20,9 @@
#include "RimIdenticalGridCaseGroup.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
@@ -172,12 +175,16 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
RimEclipseCase* mainCase = caseCollection()->reservoirs[0];
if (!mainCase->openReserviorCase())
{
QString errorMessage = QString("Could not open the Eclipse Grid file: \n") + mainCase->gridFileName() + "\n" +
"Current working directory is: \n" + QDir::currentPath();
if (RiaGuiApplication::isRunning())
{
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(),
"Error when opening project file",
"Could not open the Eclipse Grid file: \n"+ mainCase->gridFileName() + "\n"+
"Current working directory is: \n" +
QDir::currentPath());
"Error when opening project file", errorMessage);
}
RiaLogging::error(errorMessage);
return;
}

View File

@@ -19,6 +19,9 @@
#include "RimWellLogFile.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaDateStringParser.h"
#include "RiaFieldHandleTools.h"
#include "RiaQDateTimeTools.h"
@@ -123,9 +126,13 @@ RimWellLogFile* RimWellLogFile::readWellLogFile(const QString& logFilePath)
displayMessage += errorMessage;
}
if (RiaGuiApplication::isRunning())
{
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(),
"File open error",
displayMessage);
}
RiaLogging::warning(errorMessage);
delete wellLogFile;
wellLogFile = nullptr;

View File

@@ -22,6 +22,7 @@
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaWellNameComparer.h"
@@ -143,11 +144,15 @@ void RimWellPathCollection::loadDataAndUpdate()
{
QString errorMessage;
if ( !fWPath->readWellPathFile(&errorMessage, m_wellPathImporter) )
{
if (RiaGuiApplication::isRunning())
{
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(),
"File open error",
errorMessage);
}
RiaLogging::warning(errorMessage);
}
}
for ( RimWellLogFile* const wellLogFile : fWPath->wellLogFiles() )
@@ -165,6 +170,9 @@ void RimWellPathCollection::loadDataAndUpdate()
displayMessage += errorMessage;
}
RiaLogging::warning(errorMessage);
if (RiaGuiApplication::isRunning())
{
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(),
"File open error",
displayMessage);
@@ -172,6 +180,7 @@ void RimWellPathCollection::loadDataAndUpdate()
}
}
}
}
else if (mWPath)
{
mWPath->createWellPathGeometry();
@@ -372,8 +381,11 @@ void RimWellPathCollection::addWellPathFormations(const QStringList& filePaths)
outputMessage += "-----------------------------------------------";
if (fileReadSuccess)
{
if (RiaGuiApplication::isRunning())
{
QMessageBox::information(Riu3DMainWindowTools::mainWindowWidget(), "Well Picks Import", outputMessage);
}
RiaLogging::info(outputMessage);
}
@@ -510,11 +522,15 @@ void RimWellPathCollection::readWellPathFormationFiles()
{
QString errorMessage;
if (!wellPaths[wpIdx]->readWellPathFormationsFile(&errorMessage, m_wellPathFormationsImporter))
{
if (RiaGuiApplication::isRunning())
{
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(),
"File open error",
errorMessage);
}
RiaLogging::warning(errorMessage);
}
progress.setProgressDescription(QString("Reading formation file %1").arg(wpIdx));
progress.incrementProgress();
@@ -532,11 +548,15 @@ void RimWellPathCollection::reloadAllWellPathFormations()
{
QString errorMessage;
if (!wellPaths[wpIdx]->reloadWellPathFormationsFile(&errorMessage, m_wellPathFormationsImporter))
{
if (RiaGuiApplication::isRunning())
{
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(),
"File open error",
errorMessage);
}
RiaLogging::warning(errorMessage);
}
progress.setProgressDescription(QString("Reloading formation file %1").arg(wpIdx));
progress.incrementProgress();

View File

@@ -33,7 +33,10 @@ QWidget* Riu3DMainWindowTools::mainWindowWidget()
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::setActiveViewer(QWidget* subWindow)
{
if (RiuMainWindow::instance())
{
RiuMainWindow::instance()->setActiveViewer(subWindow);
}
}
//--------------------------------------------------------------------------------------------------
@@ -41,7 +44,10 @@ void Riu3DMainWindowTools::setActiveViewer(QWidget* subWindow)
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/)
{
if (RiuMainWindow::instance())
{
RiuMainWindow::instance()->setExpanded(uiItem, expanded);
}
}
//--------------------------------------------------------------------------------------------------
@@ -49,7 +55,10 @@ void Riu3DMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expand
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/)
{
if (RiuMainWindow::instance())
{
RiuMainWindow::instance()->selectAsCurrentItem(object, allowActiveViewChange);
}
}

View File

@@ -25,7 +25,10 @@
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::showPlotMainWindow()
{
if (RiaGuiApplication::isRunning())
{
RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow();
}
}
//--------------------------------------------------------------------------------------------------
@@ -33,9 +36,12 @@ void RiuPlotMainWindowTools::showPlotMainWindow()
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::setActiveViewer(QWidget* subWindow)
{
if (RiaGuiApplication::isRunning())
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
if (mpw) mpw->setActiveViewer(subWindow);
}
}
//--------------------------------------------------------------------------------------------------
@@ -43,9 +49,12 @@ void RiuPlotMainWindowTools::setActiveViewer(QWidget* subWindow)
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/)
{
if (RiaGuiApplication::isRunning())
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
if (mpw) mpw->setExpanded(uiItem, expanded);
}
}
//--------------------------------------------------------------------------------------------------
@@ -53,9 +62,12 @@ void RiuPlotMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expa
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/)
{
if (RiaGuiApplication::isRunning())
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
if (mpw) mpw->selectAsCurrentItem(object, allowActiveViewChange);
}
}
//--------------------------------------------------------------------------------------------------
@@ -63,6 +75,8 @@ void RiuPlotMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, b
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::refreshToolbars()
{
if (RiaGuiApplication::isRunning())
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
if (mpw)
@@ -70,6 +84,7 @@ void RiuPlotMainWindowTools::refreshToolbars()
mpw->updateSummaryPlotToolBar();
mpw->updateWellLogPlotToolBar();
}
}
}