[baobab] More work on cancellation
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab] More work on cancellation
- Date: Fri, 3 Aug 2012 08:36:32 +0000 (UTC)
commit f50ee40370efdea8f7dfee40bad117f5805aa4a9
Author: Paolo Borelli <pborelli gnome org>
Date: Fri Aug 3 10:34:26 2012 +0200
More work on cancellation
Do not split cancellation in two methods
src/baobab-scanner.vala | 46 ++++++++++++++++++++++------------------------
src/baobab-window.vala | 1 -
2 files changed, 22 insertions(+), 25 deletions(-)
---
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index 2834fad..8f05ab6 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -319,36 +319,16 @@ namespace Baobab {
return this.self != null;
}
- public void cancel_scan () {
- if (thread != null) {
- 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) {
successful = false;
}
if (!successful) {
- cancel_scan ();
+ cancel ();
+
+ cancellable.reset ();
+ scan_error = null;
// the thread owns a reference on the Scanner object
this.self = this;
@@ -363,6 +343,24 @@ namespace Baobab {
public virtual void cancel () {
cancellable.cancel ();
+
+ if (thread != null) {
+ 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 ();
}
public virtual void finish () throws Error {
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 900724c..0d9345f 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -537,7 +537,6 @@ namespace Baobab {
scanner.disconnect (scan_completed_handler);
scan_completed_handler = 0;
}
- scanner.cancel_scan ();
return;
} catch (Error e) {
var primary = _("Could not scan folder \"%s\" or some of the folders it contains.").printf (scanner.directory.get_parse_name ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]