summarylogtreecommitdiffstats
path: root/textentry_gtk_suppressevents.patch
blob: 05e7f32dcde72f723bf5cabbcdda6d7488a72b8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--- src/gtk/textentry_old.cpp	2018-11-01 00:03:31.952106203 +0100
+++ src/gtk/textentry.cpp	2018-11-01 00:03:43.116101966 +0100
@@ -561,10 +561,20 @@
             EventsSuppressor noevents(this);
             Remove(0, -1);
         }
-        EventsSuppressor noeventsIf(this, !(flags & SetValue_SendEvent));
-        WriteText(value);
+
+        // Testing whether value is empty here is more than just an
+        // optimization: WriteText() always generates an explicit event in
+        // wxGTK, which we need to avoid unless SetValue_SendEvent is given.
+        if ( !value.empty() )
+        {
+            // Suppress events from here even if we do need them, it's simpler
+            // to send the event below in all cases.
+            EventsSuppressor noevents(this);
+            WriteText(value);
+        }
     }
-    else if (flags & SetValue_SendEvent)
+    
+    if (flags & SetValue_SendEvent)
         SendTextUpdatedEvent(GetEditableWindow());
 
     SetInsertionPoint(0);