From aa4caf4fcb98c5658fe028fc412cde22b7f518bf Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 3 Nov 2017 22:57:40 +0100 Subject: [PATCH] Bug: The window example called a callback method after child data was deleted --- ChangeLog | 5 +++++ examples/windows.cpp | 10 +++++++--- src/flistview.cpp | 2 +- src/fwidget.cpp | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24f4207d..d1d03e11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-11-03 Markus Gans + * Small NewFont improvements + * Fixed bug: The window example called a callback method after + the child data was deleted + 2017-11-02 Markus Gans * Move fonts into the root directory diff --git a/examples/windows.cpp b/examples/windows.cpp index 219fc9a2..3c8c3c16 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -114,7 +114,11 @@ SmallWindow::SmallWindow (FWidget* parent) //---------------------------------------------------------------------- SmallWindow::~SmallWindow() { + // Remove own timer delOwnTimer(); + + // Remove all callbacks before Window::cb_destroyWindow() will be called + delCallbacks(); } //---------------------------------------------------------------------- @@ -181,9 +185,9 @@ class Window : public FDialog // Typedef typedef struct { - bool is_open; + bool is_open; FString* title; - FDialog* dgl; + SmallWindow* dgl; } win_data; @@ -416,7 +420,7 @@ void Window::cb_createWindows (FWidget*, data_ptr) if ( ! (*iter)->is_open ) { win_data* win_dat = *iter; - FDialog* win = new SmallWindow(this); + SmallWindow* win = new SmallWindow(this); win_dat->dgl = win; win_dat->is_open = true; win->setText(*(win_dat)->title); diff --git a/src/flistview.cpp b/src/flistview.cpp index 71170bc9..4acf6000 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1555,7 +1555,7 @@ void FListView::drawColumnLabels() first = h.begin() + xoffset; if ( int(h.size()) <= getClientWidth() ) - last = h.end();// - 1; + last = h.end(); else { int len = getClientWidth() + xoffset - 1; diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 9a74099f..8eb8d9a3 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -114,6 +114,7 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen) FWidget::~FWidget() // destructor { processDestroy(); + delCallbacks(); FApplication::removeQueuedEvent(this); // unset clicked widget @@ -1003,7 +1004,7 @@ void FWidget::delCallback (FWidget* cb_instance) } //---------------------------------------------------------------------- -inline void FWidget::delCallbacks() +void FWidget::delCallbacks() { // delete all callbacks from this widget