mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Guard use of nullpointer
This commit is contained in:
@@ -39,11 +39,13 @@ void RicTileWindowsFeature::applyTiling( RiuMainWindow* mainWindow, RiaDefines::
|
||||
{
|
||||
auto mode = requestedTileMode;
|
||||
|
||||
// If requested mode is set, reset tiling mode to undefined
|
||||
if ( RimProject::current()->subWindowsTileMode3DWindow() == requestedTileMode )
|
||||
mode = RiaDefines::WindowTileMode::UNDEFINED;
|
||||
if ( auto proj = RimProject::current() )
|
||||
{
|
||||
// If requested mode is set, reset tiling mode to undefined
|
||||
if ( proj->subWindowsTileMode3DWindow() == requestedTileMode ) mode = RiaDefines::WindowTileMode::UNDEFINED;
|
||||
|
||||
RimProject::current()->setSubWindowsTileMode3DWindow( mode );
|
||||
proj->setSubWindowsTileMode3DWindow( mode );
|
||||
}
|
||||
|
||||
if ( mainWindow )
|
||||
{
|
||||
@@ -91,7 +93,9 @@ void RicTileWindowsFeature::setupActionLook( QAction* actionToSetup )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTileWindowsFeature::isCommandChecked()
|
||||
{
|
||||
return RimProject::current()->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::DEFAULT;
|
||||
auto proj = RimProject::current();
|
||||
|
||||
return proj ? ( proj->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::DEFAULT ) : false;
|
||||
}
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicTilePlotWindowsFeature, "RicTilePlotWindowsFeature" );
|
||||
@@ -103,11 +107,13 @@ void RicTilePlotWindowsFeature::applyTiling( RiuPlotMainWindow* mainWindow, RiaD
|
||||
{
|
||||
auto mode = requestedTileMode;
|
||||
|
||||
// If requested mode is set, reset tiling mode to undefined
|
||||
if ( RimProject::current()->subWindowsTileModePlotWindow() == requestedTileMode )
|
||||
mode = RiaDefines::WindowTileMode::UNDEFINED;
|
||||
if ( auto proj = RimProject::current() )
|
||||
{
|
||||
// If requested mode is set, reset tiling mode to undefined
|
||||
if ( proj->subWindowsTileModePlotWindow() == requestedTileMode ) mode = RiaDefines::WindowTileMode::UNDEFINED;
|
||||
|
||||
RimProject::current()->setSubWindowsTileModePlotWindow( mode );
|
||||
proj->setSubWindowsTileModePlotWindow( mode );
|
||||
}
|
||||
|
||||
if ( mainWindow )
|
||||
{
|
||||
@@ -155,7 +161,9 @@ void RicTilePlotWindowsFeature::setupActionLook( QAction* actionToSetup )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTilePlotWindowsFeature::isCommandChecked()
|
||||
{
|
||||
return RimProject::current()->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::DEFAULT;
|
||||
auto proj = RimProject::current();
|
||||
|
||||
return proj ? ( proj->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::DEFAULT ) : false;
|
||||
}
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicTileWindowsVerticallyFeature, "RicTileWindowsVerticallyFeature" );
|
||||
@@ -199,7 +207,9 @@ void RicTileWindowsVerticallyFeature::setupActionLook( QAction* actionToSetup )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTileWindowsVerticallyFeature::isCommandChecked()
|
||||
{
|
||||
return RimProject::current()->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::VERTICAL;
|
||||
auto proj = RimProject::current();
|
||||
|
||||
return proj ? ( proj->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::VERTICAL ) : false;
|
||||
}
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicTileWindowsHorizontallyFeature, "RicTileWindowsHorizontallyFeature" );
|
||||
@@ -243,7 +253,9 @@ void RicTileWindowsHorizontallyFeature::setupActionLook( QAction* actionToSetup
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTileWindowsHorizontallyFeature::isCommandChecked()
|
||||
{
|
||||
return RimProject::current()->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::DEFAULT;
|
||||
auto proj = RimProject::current();
|
||||
|
||||
return proj ? ( proj->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::HORIZONTAL ) : false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -293,7 +305,9 @@ void RicTilePlotWindowsVerticallyFeature::setupActionLook( QAction* actionToSetu
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTilePlotWindowsVerticallyFeature::isCommandChecked()
|
||||
{
|
||||
return RimProject::current()->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::VERTICAL;
|
||||
auto proj = RimProject::current();
|
||||
|
||||
return proj ? ( proj->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::VERTICAL ) : false;
|
||||
}
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicTilePlotWindowsHorizontallyFeature, "RicTilePlotWindowsHorizontallyFeature" );
|
||||
@@ -337,5 +351,7 @@ void RicTilePlotWindowsHorizontallyFeature::setupActionLook( QAction* actionToSe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicTilePlotWindowsHorizontallyFeature::isCommandChecked()
|
||||
{
|
||||
return RimProject::current()->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::DEFAULT;
|
||||
auto proj = RimProject::current();
|
||||
|
||||
return proj ? ( proj->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::HORIZONTAL ) : false;
|
||||
}
|
||||
|
@@ -190,39 +190,40 @@ Rim3dView::~Rim3dView()
|
||||
// "\ResInsight-regression-test\ProjectFiles\ProjectFilesSmallTests\TestCase_CoViz-Simple" when a view used as
|
||||
// comparison view was deleted.
|
||||
|
||||
RimProject* proj = RimProject::current();
|
||||
|
||||
std::vector<Rim3dView*> allViews;
|
||||
proj->allViews( allViews );
|
||||
|
||||
for ( auto v : allViews )
|
||||
if ( auto proj = RimProject::current() )
|
||||
{
|
||||
if ( v->activeComparisonView() == this )
|
||||
std::vector<Rim3dView*> allViews;
|
||||
proj->allViews( allViews );
|
||||
|
||||
for ( auto v : allViews )
|
||||
{
|
||||
v->setComparisonView( nullptr );
|
||||
v->scheduleCreateDisplayModelAndRedraw();
|
||||
if ( v->activeComparisonView() == this )
|
||||
{
|
||||
v->setComparisonView( nullptr );
|
||||
v->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( proj && this->isMasterView() )
|
||||
{
|
||||
RimViewLinker* viewLinker = this->assosiatedViewLinker();
|
||||
viewLinker->setMasterView( nullptr );
|
||||
if ( this->isMasterView() )
|
||||
{
|
||||
RimViewLinker* viewLinker = this->assosiatedViewLinker();
|
||||
viewLinker->setMasterView( nullptr );
|
||||
|
||||
delete proj->viewLinkerCollection->viewLinker();
|
||||
proj->viewLinkerCollection->viewLinker = nullptr;
|
||||
delete proj->viewLinkerCollection->viewLinker();
|
||||
proj->viewLinkerCollection->viewLinker = nullptr;
|
||||
|
||||
proj->uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
proj->uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
|
||||
RimViewController* vController = this->viewController();
|
||||
if ( proj && vController )
|
||||
{
|
||||
vController->setManagedView( nullptr );
|
||||
vController->ownerViewLinker()->removeViewController( vController );
|
||||
delete vController;
|
||||
RimViewController* vController = this->viewController();
|
||||
if ( vController )
|
||||
{
|
||||
vController->setManagedView( nullptr );
|
||||
vController->ownerViewLinker()->removeViewController( vController );
|
||||
delete vController;
|
||||
|
||||
proj->uiCapability()->updateConnectedEditors();
|
||||
proj->uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
if ( RiaApplication::instance()->activeReservoirView() == this )
|
||||
|
@@ -44,11 +44,15 @@ RiuMdiArea::~RiuMdiArea()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaDefines::WindowTileMode RiuMdiArea::tileMode() const
|
||||
{
|
||||
auto* mainWindow = dynamic_cast<RiuMainWindow*>( window() );
|
||||
if ( mainWindow ) return RimProject::current()->subWindowsTileMode3DWindow();
|
||||
auto proj = RimProject::current();
|
||||
if ( proj )
|
||||
{
|
||||
auto* mainWindow = dynamic_cast<RiuMainWindow*>( window() );
|
||||
if ( mainWindow ) return proj->subWindowsTileMode3DWindow();
|
||||
|
||||
auto* plotMainWindow = dynamic_cast<RiuPlotMainWindow*>( window() );
|
||||
if ( plotMainWindow ) return RimProject::current()->subWindowsTileModePlotWindow();
|
||||
auto* plotMainWindow = dynamic_cast<RiuPlotMainWindow*>( window() );
|
||||
if ( plotMainWindow ) return proj->subWindowsTileModePlotWindow();
|
||||
}
|
||||
|
||||
return RiaDefines::WindowTileMode::UNDEFINED;
|
||||
}
|
||||
|
Reference in New Issue
Block a user