[baobab/reroot-view: 5/35] Fix the cancellation logic
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/reroot-view: 5/35] Fix the cancellation logic
- Date: Fri, 26 Jun 2020 08:58:32 +0000 (UTC)
commit d605166fee6ca5bd0115b7b6eefaa4db4aa76492
Author: Stefano Facchini <stefano facchini gmail com>
Date: Thu Jun 18 19:38:15 2020 +0200
Fix the cancellation logic
The cancellation error was actually never reported because the Results object
carrying it was discarded in cancel_and_reset() when draining the async queue,
so it never had a chance of being processed.
Instead we synthetize a cancellation error ourselves and properly emit the
completed() signal.
src/baobab-scanner.vala | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
---
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index b3ba68c..7ee5f8e 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -373,18 +373,9 @@ namespace Baobab {
max_depth = results.max_depth;
}
- // If the user cancelled abort the scan and
- // report CANCELLED as the error, otherwise
- // consider the error not fatal and report the
- // first error we encountered
- if (results.error != null) {
- if (results.error is IOError.CANCELLED) {
- scan_error = results.error;
- completed ();
- return false;
- } else if (scan_error == null) {
- scan_error = results.error;
- }
+ // Report the first error we encountered
+ if (results.error != null && scan_error == null) {
+ scan_error = results.error;
}
if (results.parent == null) {
@@ -454,7 +445,9 @@ namespace Baobab {
public void cancel () {
if (!successful) {
cancel_and_reset ();
+ scan_error = new IOError.CANCELLED ("Scan was cancelled");
}
+ completed ();
}
public void finish () throws Error {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]