mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4509 Guard access to gui application code in import and well path code to avoid crashes in console mode
This commit is contained in:
@@ -180,10 +180,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file
|
||||
|
||||
project->activeOilField()->completionTemplateCollection()->setDefaultUnitSystemBasedOnLoadedCases();
|
||||
|
||||
if (RiaGuiApplication::isRunning())
|
||||
{
|
||||
RiuPlotMainWindowTools::refreshToolbars();
|
||||
}
|
||||
|
||||
if (openedFilesOut)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -32,25 +32,34 @@ QWidget* Riu3DMainWindowTools::mainWindowWidget()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Riu3DMainWindowTools::setActiveViewer(QWidget* subWindow)
|
||||
{
|
||||
if (RiuMainWindow::instance())
|
||||
{
|
||||
RiuMainWindow::instance()->setActiveViewer(subWindow);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Riu3DMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/)
|
||||
{
|
||||
if (RiuMainWindow::instance())
|
||||
{
|
||||
RiuMainWindow::instance()->setExpanded(uiItem, expanded);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Riu3DMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/)
|
||||
{
|
||||
if (RiuMainWindow::instance())
|
||||
{
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(object, allowActiveViewChange);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,44 +24,58 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotMainWindowTools::showPlotMainWindow()
|
||||
{
|
||||
if (RiaGuiApplication::isRunning())
|
||||
{
|
||||
RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotMainWindowTools::setActiveViewer(QWidget* subWindow)
|
||||
{
|
||||
if (RiaGuiApplication::isRunning())
|
||||
{
|
||||
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
|
||||
if (mpw) mpw->setActiveViewer(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);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/)
|
||||
{
|
||||
if (RiaGuiApplication::isRunning())
|
||||
{
|
||||
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
|
||||
if (mpw) mpw->selectAsCurrentItem(object, allowActiveViewChange);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotMainWindowTools::refreshToolbars()
|
||||
{
|
||||
if (RiaGuiApplication::isRunning())
|
||||
{
|
||||
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
|
||||
@@ -71,5 +85,6 @@ void RiuPlotMainWindowTools::refreshToolbars()
|
||||
mpw->updateWellLogPlotToolBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user