[gparted/psusi/refactor] fixup! Add proper cancel support (#601239)



commit 476e88ed7beef3054d0e29b69ff67760b8cea0b1
Author: Phillip Susi <psusi ubuntu com>
Date:   Mon Mar 4 18:49:47 2013 -0500

    fixup! Add proper cancel support (#601239)
    
    Store cancel flag in operation detail so new sub operations can be canceled
    immediately when they are added.

 include/OperationDetail.h |    2 +-
 src/OperationDetail.cc    |   11 ++++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/include/OperationDetail.h b/include/OperationDetail.h
index 0db4e15..3c6dafb 100644
--- a/include/OperationDetail.h
+++ b/include/OperationDetail.h
@@ -73,7 +73,7 @@ public:
 private:
        void on_update( const OperationDetail & operationdetail ) ;
        void cancel( bool force );
-       
+       char cancelflag;
        Glib::ustring description ;
        OperationDetailStatus status ; 
 
diff --git a/src/OperationDetail.cc b/src/OperationDetail.cc
index f366d60..86b4127 100644
--- a/src/OperationDetail.cc
+++ b/src/OperationDetail.cc
@@ -22,12 +22,13 @@
 namespace GParted
 {
 
-OperationDetail::OperationDetail() : fraction( -1 ), status( STATUS_NONE ), time_start( -1 ), time_elapsed( 
-1 )
+OperationDetail::OperationDetail() : fraction( -1 ), cancelflag( 0 ), status( STATUS_NONE ), time_start( -1 
),
+                                    time_elapsed( -1 )
 {
 }
 
 OperationDetail::OperationDetail( const Glib::ustring & description, OperationDetailStatus status, Font font 
) :
-       fraction( -1 ), status( STATUS_NONE ), time_start( -1 ), time_elapsed( -1 )
+       fraction( -1 ), cancelflag( 0 ), status( STATUS_NONE ), time_start( -1 ), time_elapsed( -1 )
 {
        set_description( description, font );
        set_status( status );
@@ -127,7 +128,8 @@ void OperationDetail::add_child( const OperationDetail & operationdetail )
        sub_details .back() .signal_update .connect( sigc::mem_fun( this, &OperationDetail::on_update ) ) ;
        sub_details.back().cancelconnection = signal_cancel.connect(
                                sigc::mem_fun( &sub_details.back(), &OperationDetail::cancel ) );
-       
+       if ( cancelflag )
+               sub_details.back().cancel( cancelflag == 2 );
        on_update( sub_details .back() ) ;
 }
        
@@ -158,6 +160,9 @@ void OperationDetail::on_update( const OperationDetail & operationdetail )
 
 void OperationDetail::cancel( bool force )
 {
+       if ( force )
+               cancelflag = 2;
+       else cancelflag = 1;
        signal_cancel(force);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]