diff options
author | Colomban Wendling <ban@herbesfolles.org> | 2014-09-01 20:03:13 +0200 |
---|---|---|
committer | Colomban Wendling <ban@herbesfolles.org> | 2014-09-01 20:03:13 +0200 |
commit | f90a670f7e4e8e141f833881b69c60d2bd4dbd19 (patch) | |
tree | 48e071304e57ad15f72c66da916e2967d69d1008 | |
parent | b7efbe3c5c3710be132736bc4a25985729f37e5d (diff) | |
download | scintilla-mirror-f90a670f7e4e8e141f833881b69c60d2bd4dbd19.tar.gz |
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].
-rw-r--r-- | gtk/PlatGTK.cxx | 25 |
1 files changed, 22 insertions, 3 deletions
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<ListBox*>(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); |