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
This commit is contained in:
Vadim Zeitlin
2013-02-15 12:40:13 +00:00
parent 116d7e5805
commit bdffa92004
2 changed files with 10 additions and 1 deletions

View File

@@ -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;

View File

@@ -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();