From bdffa920040190876d7241f5e2b8fe489d804b9c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 15 Feb 2013 12:40:13 +0000 Subject: [PATCH] Don't connect to the same signal multiple times in wxGTK wxClipboard. We called g_signal_connect("selection_get") in wxClipboard code each time its AddData() method was called. This resulted in progressive but noticeable slowdown as the handler was called more and more times. Only connect to the handler once now. Closes #15038. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73518 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/clipbrd.h | 3 +++ src/gtk/clipbrd.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/wx/gtk/clipbrd.h b/include/wx/gtk/clipbrd.h index 4af988f80c..ff24ad33dc 100644 --- a/include/wx/gtk/clipbrd.h +++ b/include/wx/gtk/clipbrd.h @@ -118,6 +118,9 @@ private: GtkWidget *m_clipboardWidget; // for getting and offering data GtkWidget *m_targetsWidget; // for getting list of supported formats + // ID of the connection to "selection_get" signal, initially 0. + unsigned long m_idSelectionGetHandler; + bool m_open; bool m_formatSupported; diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index 8b3d228a4f..e41b5e654c 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -434,6 +434,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject) wxClipboard::wxClipboard() { + m_idSelectionGetHandler = 0; + m_open = false; m_dataPrimary = @@ -642,9 +644,13 @@ bool wxClipboard::AddData( wxDataObject *data ) AddSupportedTarget(format); } - g_signal_connect (m_clipboardWidget, "selection_get", + if ( !m_idSelectionGetHandler ) + { + m_idSelectionGetHandler = g_signal_connect ( + m_clipboardWidget, "selection_get", G_CALLBACK (selection_handler), GUINT_TO_POINTER (gtk_get_current_event_time()) ); + } // tell the world we offer clipboard data return SetSelectionOwner(); -- 2.47.2