mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
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.
15 lines
669 B
C++
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() );
|
|
}
|