From d3f59798730ba5cc557db7489bd049da3309482d Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 28 Jul 2016 01:04:27 +0200 Subject: [PATCH] Segmentation fault fix --- src/fdialog.cpp | 12 +++++++----- src/fmenu.cpp | 6 +++++- src/fstatusbar.cpp | 1 + src/fwidget.cpp | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 65e52031..3f15ffa1 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -42,18 +42,20 @@ FDialog::FDialog (const FString& txt, FWidget* parent) //---------------------------------------------------------------------- FDialog::~FDialog() // destructor { - FApplication* fapp; - + FApplication* fapp = static_cast(getRootWidget()); + bool is_quit = fapp->isQuit(); delete dialog_menu; dgl_menuitem = 0; delete accelerator_list; accelerator_list = 0; - activatePrevWindow(); + + if ( ! is_quit ) + switchToPrevWindow(); + delWindow(this); delDialog(this); - fapp = static_cast(getRootWidget()); - if ( ! fapp->quit_now ) + if ( ! is_quit ) { const FRect& geometry = getGeometryGlobalShadow(); restoreVTerm (geometry); diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 13cd7fa5..3822b4e6 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -69,7 +69,11 @@ FMenu::FMenu (const char* txt, FWidget* parent) //---------------------------------------------------------------------- FMenu::~FMenu() { - activatePrevWindow(); + FApplication* fapp = static_cast(getRootWidget()); + + if ( ! fapp->isQuit() ) + switchToPrevWindow(); + delWindow(this); const FRect& geometry = getGeometryGlobalShadow(); diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 07774d67..ac14bf82 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -177,6 +177,7 @@ FStatusBar::~FStatusBar() iter = keylist.erase(iter); } } + setStatusBar(0); } diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 807bce9d..c8f4d26f 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -537,7 +537,7 @@ void FWidget::setStatusBar (FStatusBar* sbar) if ( ! sbar || statusbar == sbar ) return; - if ( statusbar ) + if ( statusbar && sbar != 0 ) delete statusbar; statusbar = sbar;