https://github.com/wxWidgets/wxWidgets/pull/26006
(3 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
It would be appropriate to have a description here of how the crash can be reproduced. Maybe a stack trace too.
How about we do it like this instead?
diff --git a/src/gtk/textentry.cpp b/src/gtk/textentry.cpp index 200d2e727f..b3d8f00cf8 100644 --- a/src/gtk/textentry.cpp +++ b/src/gtk/textentry.cpp @@ -43,6 +43,7 @@ class wxTextCoalesceData public: wxTextCoalesceData(GtkWidget* widget, gulong handlerAfterKeyPress) : m_handlerAfterKeyPress(handlerAfterKeyPress) + , m_widget(widget) { m_inKeyPress = false; m_pendingTextChanged = false; @@ -52,12 +53,17 @@ public: g_signal_handler_block(widget, m_handlerAfterKeyPress); } - void StartHandlingKeyPress(GtkWidget* widget) + ~wxTextCoalesceData() + { + g_signal_handler_disconnect(m_widget, m_handlerAfterKeyPress); + } + + void StartHandlingKeyPress() { m_inKeyPress = true; m_pendingTextChanged = false; - g_signal_handler_unblock(widget, m_handlerAfterKeyPress); + g_signal_handler_unblock(m_widget, m_handlerAfterKeyPress); } bool SetPendingIfInKeyPress() @@ -70,9 +76,9 @@ public: return true; } - bool EndHandlingKeyPressAndCheckIfPending(GtkWidget* widget) + bool EndHandlingKeyPressAndCheckIfPending() { - g_signal_handler_block(widget, m_handlerAfterKeyPress); + g_signal_handler_block(m_widget, m_handlerAfterKeyPress); wxASSERT( m_inKeyPress ); m_inKeyPress = false; @@ -89,6 +95,7 @@ private: bool m_inKeyPress; bool m_pendingTextChanged; const gulong m_handlerAfterKeyPress; + GtkWidget* const m_widget; wxDECLARE_NO_COPY_CLASS(wxTextCoalesceData); }; @@ -120,14 +127,14 @@ extern "C" { // to send a single wxEVT_TEXT even if we received several (typically two, when // the selected text in the control is replaced by new text) "changed" signals. static gboolean -wx_gtk_text_after_key_press(GtkWidget* widget, +wx_gtk_text_after_key_press(GtkWidget*, GdkEventKey* WXUNUSED(gdk_event), wxTextEntry* entry) { wxTextCoalesceData* const data = entry->GTKGetCoalesceData(); wxCHECK_MSG( data, FALSE, "must be non-null if this handler is called" ); - if ( data->EndHandlingKeyPressAndCheckIfPending(widget) ) + if ( data->EndHandlingKeyPressAndCheckIfPending() ) { entry->GTKOnTextChanged(); } @@ -976,7 +983,7 @@ void wxTextEntry::GTKEntryOnKeypress(GtkWidget* widget) const m_coalesceData = new wxTextCoalesceData(widget, handler); } - m_coalesceData->StartHandlingKeyPress(widget); + m_coalesceData->StartHandlingKeyPress(); } int wxTextEntry::GTKEntryIMFilterKeypress(GdkEventKey* event) const
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks, that one works as well - and looks as if it would not break backward comp, so it could be backported.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@RobertRoeb pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I have applied your patch and added a test to the text sample
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()