[baobab] More cancellation fixes
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab] More cancellation fixes
- Date: Fri, 3 Aug 2012 08:36:27 +0000 (UTC)
commit 335f8864cf83642b2b7a3ada01eabed795e560ae
Author: Paolo Borelli <pborelli gnome org>
Date: Fri Aug 3 10:01:26 2012 +0200
More cancellation fixes
Reassign the thread scanner reference when creating the new tread, properly
remove the process_result timeout when cancelling and clear the any
previous error
src/baobab-scanner.vala | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index f621941..2834fad 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -78,7 +78,8 @@ namespace Baobab {
}
}
- GLib2.Thread? thread;
+ GLib2.Thread? thread = null;
+ uint process_result_idle = 0;
HardLink[] hardlinks;
HashTable<File, unowned File> excluded_locations;
@@ -323,23 +324,38 @@ namespace Baobab {
thread.join ();
thread = null;
}
+
+ if (process_result_idle != 0) {
+ GLib.Source.remove (process_result_idle);
+ process_result_idle = 0;
+ }
+
+ // Drain the async queue
var tmp = results_queue.try_pop ();
while (tmp != null) {
tmp = results_queue.try_pop ();
}
+
base.clear ();
+
cancellable.reset ();
+ scan_error = null;
}
public void scan (bool force) {
if (force) {
- cancel_scan ();
successful = false;
}
if (!successful) {
+ cancel_scan ();
+
+ // the thread owns a reference on the Scanner object
+ this.self = this;
+
thread = new GLib2.Thread ("scanner", scan_in_thread);
- Timeout.add (100, process_results);
+
+ process_result_idle = Timeout.add (100, process_results);
} else {
completed ();
}
@@ -383,9 +399,6 @@ namespace Baobab {
excluded_locations.remove (directory);
results_queue = new AsyncQueue<ResultsArray> ();
-
- // the thread owns a reference on the Scanner object
- this.self = this;
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]