Fix crash if main window is null

When launching a script, the main window must be created. It is the Process Monitor that received info from the process and passes the text to process monitor and Message Panel.
This commit is contained in:
Magne Sjaastad 2023-07-07 16:11:35 +02:00
parent 8b7144d987
commit 35e2e43c3a

View File

@ -19,6 +19,8 @@
#include "RicExecuteScriptFeature.h"
#include "RiaGuiApplication.h"
#include "RicExecuteLastUsedScriptFeature.h"
#include "RicScriptFeatureImpl.h"
@ -75,6 +77,15 @@ void RicExecuteScriptFeature::setupActionLook( QAction* actionToSetup )
void RicExecuteScriptFeature::executeScript( RimCalcScript* calcScript )
{
RiuMainWindow* mainWindow = RiuMainWindow::instance();
if ( !mainWindow )
{
// It is required to have a main window for the process monitor. If the process monitor is not present, no text can be displayed in
// message window, and text feedback from script is not possible to see in the user interface.
RiaGuiApplication* app = RiaGuiApplication::instance();
mainWindow = app->getOrCreateAndShowMainWindow();
}
mainWindow->showProcessMonitorDockPanel();
RiaApplication* app = RiaApplication::instance();