From 182ac19de82a853ab464d3626215d1e4668e5be8 Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 1 Jun 2006 10:40:30 +0000 Subject: [PATCH] PAL12486: SIGSEGV when closing a study. Nullify member myApp of module to suppress invalid pointer usage. --- src/CAM/CAM_Module.cxx | 15 +++++++++++++++ src/CAM/CAM_Module.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index 1a6852fed..9b37b3347 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -26,6 +26,9 @@ #include #include +#include +#include + /*!Icon.*/ static const char* ModuleIcon[] = { "20 20 2 1", @@ -84,6 +87,11 @@ CAM_Module::~CAM_Module() void CAM_Module::initialize( CAM_Application* app ) { myApp = app; + if (myApp) { + SUIT_Session* aSession = SUIT_Session::session(); + connect(aSession, SIGNAL( applicationClosed( SUIT_Application* ) ), + this, SLOT( onApplicationClosed( SUIT_Application* ) )); + } } /*!\retval Module icon.*/ @@ -159,6 +167,13 @@ void CAM_Module::studyChanged( SUIT_Study* , SUIT_Study* ) { } +/*!Public slot, nullify application pointer if the application was closed.*/ +void CAM_Module::onApplicationClosed( SUIT_Application* theApp ) +{ + if (myApp == theApp) + myApp = NULL; +} + /*!Create and return new instance of CAM_DataModel.*/ CAM_DataModel* CAM_Module::createDataModel() { diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index 3976a197b..3409905e7 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -28,6 +28,7 @@ class QAction; class SUIT_Study; +class SUIT_Application; class CAM_Study; class CAM_DataModel; class CAM_Application; @@ -86,6 +87,8 @@ public slots: virtual void studyClosed( SUIT_Study* ); virtual void studyChanged( SUIT_Study*, SUIT_Study* ); + virtual void onApplicationClosed( SUIT_Application* ); + protected: virtual CAM_DataModel* createDataModel(); -- 2.39.2