Files
ResInsight/ApplicationLibCode/UnitTests/RimDockWindowController-Test.cpp
T
Magne Sjaastad 7f99498072 Fix crash in RimDockWindowController when view widget creation fails
Guarded two unconditional null derefs: dockWidget->setWidget(viewWidget) when viewWidget creation fails, and viewPdmObject() in handleViewerDeletion() when no view has ever been assigned to control. Added regression test for the handleViewerDeletion() case; the setWidget() path requires a running GUI/main window and isn't reachable from the headless unit test harness.
2026-10-05 19:56:10 +02:00

15 lines
669 B
C++

#include "gtest/gtest.h"
#include "RimDockWindowController.h"
//--------------------------------------------------------------------------------------------------
/// handleViewerDeletion() used to dereference viewPdmObject() (m_viewToControl) unconditionally.
/// Calling it before setViewToControl() has ever been called (m_viewToControl is null) must not crash.
//--------------------------------------------------------------------------------------------------
TEST( RimDockWindowControllerTest, HandleViewerDeletionWithoutViewToControlDoesNotCrash )
{
RimDockWindowController controller;
EXPECT_NO_FATAL_FAILURE( controller.handleViewerDeletion() );
}