[Xfce4-commits] <midori:master> Wrap filling in completions to ensure cancellation
Christian Dywan
noreply at xfce.org
Mon Nov 19 01:58:02 CET 2012
Updating branch refs/heads/master
to aa6e7151f8d6359f926563f0365b96e847d7f4da (commit)
from f36fae3d2c2ad7737c3d92399c140ccfcea55b7b (commit)
commit aa6e7151f8d6359f926563f0365b96e847d7f4da
Author: Christian Dywan <christian at twotoasts.de>
Date: Mon Nov 19 01:52:26 2012 +0100
Wrap filling in completions to ensure cancellation
Guarantee starting completions in order and cancelling reliably.
midori/midori-completion.vala | 24 +++++++++---------------
tests/completion.vala | 2 --
2 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/midori/midori-completion.vala b/midori/midori-completion.vala
index 0d64ee1..f7d23f1 100644
--- a/midori/midori-completion.vala
+++ b/midori/midori-completion.vala
@@ -78,12 +78,7 @@ namespace Midori {
return false;
}
- private void fill_model (GLib.Object? object, AsyncResult result) {
- var completion = object as Completion;
- List<Suggestion>? suggestions = completion.complete.end (result);
- if (suggestions == null)
- return;
-
+ private void fill_model (Midori.Completion completion, List<Midori.Suggestion>? suggestions) {
if (need_to_clear) {
model.clear ();
need_to_clear = false;
@@ -111,6 +106,12 @@ namespace Midori {
public signal void populated (uint count);
+ private async void complete_wrapped (Completion completion, string text, string? action, Cancellable cancellable) {
+ List<Midori.Suggestion>? suggestions = yield completion.complete (text, action, cancellable);
+ if (!cancellable.is_cancelled () && suggestions != null)
+ fill_model (completion, suggestions);
+ }
+
public async void complete (string text) {
if (cancellable != null)
cancellable.cancel ();
@@ -119,14 +120,7 @@ namespace Midori {
foreach (var completion in completions) {
if (completion.can_complete (text))
- completion.complete.begin (text, null, cancellable, fill_model);
-
- uint src = Idle.add (complete.callback);
- yield;
- Source.remove (src);
-
- if (cancellable.is_cancelled ())
- break;
+ complete_wrapped.begin (completion, text, null, cancellable);
}
}
@@ -145,7 +139,7 @@ namespace Midori {
foreach (var completion in completions) {
if (completion.can_action (action))
- completion.complete.begin (text, action, cancellable, fill_model);
+ complete_wrapped.begin (completion, text, action, cancellable);
}
}
}
diff --git a/tests/completion.vala b/tests/completion.vala
index 00cbf18..e265128 100644
--- a/tests/completion.vala
+++ b/tests/completion.vala
@@ -78,7 +78,6 @@ void completion_autocompleter () {
error ("Expected %s but got %s", "First", title);
/* Cancellation */
- /*
autocompleter.complete.begin ("");
completion.test_suggestions = 3;
autocompleter.complete.begin ("");
@@ -86,7 +85,6 @@ void completion_autocompleter () {
int n = autocompleter.model.iter_n_children (null);
if (n != 3)
error ("Expected %d but got %d", 3, n);
- */
}
struct TestCaseCompletion {
More information about the Xfce4-commits
mailing list