From 78d0393cc068103fd6bf13e5f52b74f939fef1c5 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 11 Feb 2015 18:05:15 +0000 Subject: [PATCH] avoid GDK assertion "impl_window->update_freeze_count > 0" on Ubuntu when enabling frozen window closes #16795 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 8235a38288..a5c4d171cf 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3319,13 +3319,52 @@ bool wxWindowGTK::Show( bool show ) return true; } +static bool GetFrozen(wxWindowGTK* win, wxVector& vector) +{ + bool scroll = + GTK_IS_SCROLLED_WINDOW(win->m_widget) || GTK_IS_SCROLLBAR(win->m_widget); + + if (win->IsFrozen()) + vector.push_back(win); + + wxWindowList& children = win->GetChildren(); + for (wxWindowList::iterator i = children.begin(); i != children.end(); ++i) + { + if (GetFrozen(*i, vector)) + scroll = true; + } + + return scroll; +} + void wxWindowGTK::DoEnable( bool enable ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); + wxVector frozen; + if (enable) + { + // Ubuntu overlay scrollbar can cause GdkWindow.impl_window to change + // (by indirectly invoking gdk_window_ensure_native()), which messes up + // the freeze count. Avoid this by temporarily un-freezing window hierarchy. + if (GetFrozen(this, frozen)) + { + for (unsigned i = frozen.size(); i--;) + frozen[i]->DoThaw(); + } + else + frozen.clear(); + } + gtk_widget_set_sensitive( m_widget, enable ); if (m_wxwindow && (m_wxwindow != m_widget)) gtk_widget_set_sensitive( m_wxwindow, enable ); + + if (enable) + { + for (unsigned i = frozen.size(); i--;) + frozen[i]->DoFreeze(); + } } int wxWindowGTK::GetCharHeight() const