#7778 Check for valid pointer to main window before use

This commit is contained in:
Magne Sjaastad
2022-05-21 16:11:55 +02:00
parent 886f5e3295
commit ccfc0e25bc
4 changed files with 29 additions and 28 deletions

View File

@@ -61,7 +61,10 @@ void RicExitApplicationFeature::onActionTriggered( bool isChecked )
topLevelWidget->hide();
}
// Close just the main window, it'll take care of closing the plot window
app->mainWindow()->close();
if ( app->mainWindow() )
{
app->mainWindow()->close();
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -136,13 +136,17 @@ caf::PdmUiTreeView* RicToggleItemsFeatureImpl::findTreeView( const caf::PdmUiIte
return customActiveTreeView;
}
caf::PdmUiTreeView* activeTree = RiuMainWindow::instance()->getTreeViewWithItem( uiItem );
if ( activeTree ) return activeTree;
auto* main3dWindow = RiaGuiApplication::instance()->mainWindow();
if ( main3dWindow )
{
auto activeTree = main3dWindow->getTreeViewWithItem( uiItem );
if ( activeTree ) return activeTree;
}
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
auto* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
if ( mainPlotWindow )
{
activeTree = mainPlotWindow->getTreeViewWithItem( uiItem );
auto activeTree = mainPlotWindow->getTreeViewWithItem( uiItem );
if ( activeTree )
{
return activeTree;