From f90a670f7e4e8e141f833881b69c60d2bd4dbd19 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Mon, 1 Sep 2014 20:03:13 +0200 Subject: GTK: cache the completion popup window This avoids creating and destroying windows quickly under stress, which may lead to XID collisions. See e.g. https://bugzilla.gnome.org/show_bug.cgi?id=581526 and https://bugzilla.gnome.org/show_bug.cgi?id=590690 Closes [bugs:1649]. --- gtk/PlatGTK.cxx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'gtk') diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 2637e5d99..c69571669 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -1225,9 +1225,19 @@ Surface *Surface::Allocate(int) { Window::~Window() {} void Window::Destroy() { - if (wid) - gtk_widget_destroy(GTK_WIDGET(wid)); - wid = 0; + if (wid) { + ListBox *listbox = dynamic_cast(this); + if (listbox) { + gtk_widget_hide(GTK_WIDGET(wid)); + listbox->Clear(); + // resize the window to the smallest possible size for it to adapt + // to future content + gtk_window_resize(GTK_WINDOW(wid), 1, 1); + } else { + gtk_widget_destroy(GTK_WIDGET(wid)); + wid = 0; + } + } } bool Window::HasFocus() { @@ -1432,6 +1442,10 @@ public: g_hash_table_foreach((GHashTable *) pixhash, list_image_free, NULL); g_hash_table_destroy((GHashTable *) pixhash); } + if (wid) { + gtk_widget_destroy(GTK_WIDGET(wid)); + wid = 0; + } } virtual void SetFont(Font &font); virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_); @@ -1524,6 +1538,11 @@ static void StyleSet(GtkWidget *w, GtkStyle*, void*) { } void ListBoxX::Create(Window &, int, Point, int, bool, int) { + if (wid) { + gtk_widget_realize(PWidget(wid)); + return; + } + wid = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget *frame = gtk_frame_new(NULL); -- cgit v1.2.3