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 | e536b6f6d5a5125f3276b3eaf9686933436f6b9c (patch) | |
tree | 64d73f54704f42abc7b3e78b2d524da3f606792d | |
parent | be38580f4a6cd0d76312ce41ff8171526b864ba3 (diff) | |
download | scintilla-mirror-e536b6f6d5a5125f3276b3eaf9686933436f6b9c.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); |