From e99ebc6e2e14861006365bd260cc1682665879d0 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 20 Mar 2015 14:55:17 +0800 Subject: [PATCH] fix a crash error it occurs when deleting a window in its certain event --- source/gui/detail/linux_X11/bedrock.cpp | 5 +++-- source/gui/detail/win32/bedrock.cpp | 4 ++++ source/gui/widgets/listbox.cpp | 4 +--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index d6546f08..886f1493 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -719,12 +719,11 @@ namespace detail if(kill_focus != new_focus) brock.wd_manager.do_lazy_refresh(kill_focus, false); } + auto retain = msgwnd->together.event_ptr; msgwnd->root_widget->other.attribute.root->context.focus_changed = false; - context.event_window = msgwnd; pressed_wd = nullptr; - //make_eventinfo(ei, msgwnd, message, xevent); msgwnd->flags.action = mouse_action::pressed; arg_mouse arg; assign_arg(arg, msgwnd, ButtonPress, xevent); @@ -774,6 +773,8 @@ namespace detail msgwnd->flags.action = mouse_action::normal; if(msgwnd->flags.enabled) { + auto retain = msgwnd->together.event_ptr; + arg_mouse arg; assign_arg(arg, msgwnd, message, xevent); diff --git a/source/gui/detail/win32/bedrock.cpp b/source/gui/detail/win32/bedrock.cpp index 7820227c..00968a6a 100644 --- a/source/gui/detail/win32/bedrock.cpp +++ b/source/gui/detail/win32/bedrock.cpp @@ -948,6 +948,8 @@ namespace detail arg_mouse arg; assign_arg(arg, msgwnd, message, pmdec); msgwnd->flags.action = mouse_action::pressed; + + auto retain = msgwnd->together.events_ptr; if (brock.emit(event_code::mouse_down, msgwnd, arg, true, &context)) { //If a root_window is created during the mouse_down event, Nana.GUI will ignore the mouse_up event. @@ -982,6 +984,8 @@ namespace detail msgwnd->flags.action = mouse_action::normal; if(msgwnd->flags.enabled) { + auto retain = msgwnd->together.events_ptr; + nana::arg_mouse arg; assign_arg(arg, msgwnd, message, pmdec); diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 6deb2b20..ef7a7130 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -8,8 +8,7 @@ * http://www.boost.org/LICENSE_1_0.txt) * * @file: nana/gui/widgets/listbox.cpp - * @patchs: - * Jan 03 2012, unsigned to std::size_t conversion fail for x64, Hiroshi Seki + * @contributors: Hiroshi Seki, qPCR4vir */ #include @@ -2614,7 +2613,6 @@ namespace nana { const auto & header = essence_->header.column(index); auto it_bgcolor = bgcolor; - //auto it_fgcolor = fgcolor; if ((item.cells.size() > index) && (header.pixels > 5)) {