[geary/mjog/fix-find-crash] ConversationWebView: Fix crash performing find in conversation
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/fix-find-crash] ConversationWebView: Fix crash performing find in conversation
- Date: Sat, 29 Aug 2020 07:56:40 +0000 (UTC)
commit 87a5a3e78dece4625433590ad3c5768b0a2aa5d2
Author: Michael Gratton <mike vee net>
Date: Sat Aug 29 13:07:55 2020 +1000
ConversationWebView: Fix crash performing find in conversation
WebKit.FindController seems to be signalling found/not-found/cancelled
signals multiple times when typing text in the find entry (perhaps
when not found and cancelled due to the next keystroke?), causing the
async call to be resumed more than once and thus triggering a vala
assertion ensuring that doesn't happen.
This commit adds guards so that once the method has resumed once, it is
not resumed again.
.../conversation-viewer/conversation-web-view.vala | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-web-view.vala
b/src/client/conversation-viewer/conversation-web-view.vala
index 9832efa58..70e5c6331 100644
--- a/src/client/conversation-viewer/conversation-web-view.vala
+++ b/src/client/conversation-viewer/conversation-web-view.vala
@@ -118,20 +118,27 @@ public class ConversationWebView : ClientWebView {
// first term
uint found = 0;
+ bool finished = false;
SourceFunc callback = this.highlight_search_terms.callback;
ulong found_handler = controller.found_text.connect((count) => {
- found = count;
- callback();
+ if (!finished) {
+ found = count;
+ callback();
+ }
});
ulong not_found_handler = controller.failed_to_find_text.connect(() => {
- callback();
+ if (!finished) {
+ callback();
+ }
});
ulong cancelled_handler = cancellable.cancelled.connect(() => {
- // Do this at idle since per the docs for
- // GLib.Cancellable.disconnect, disconnecting a
- // handler from within a handler causes a deadlock.
- GLib.Idle.add(() => callback());
+ if (!finished) {
+ // Do this at idle since per the docs for
+ // GLib.Cancellable.disconnect, disconnecting a
+ // handler from within a handler causes a deadlock.
+ GLib.Idle.add(() => callback());
+ }
});
controller.search(
@@ -143,6 +150,7 @@ public class ConversationWebView : ClientWebView {
yield;
+ finished = true;
controller.disconnect(found_handler);
controller.disconnect(not_found_handler);
cancellable.disconnect(cancelled_handler);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]