[gparted/psusi/refactor: 14/16] Clean up OperationDetail timer initialization



commit eed20da77a9f7c88f0f64b7f822aa82a774ee3af
Author: Phillip Susi <psusi ubuntu com>
Date:   Sun Jan 27 20:51:19 2013 -0500

    Clean up OperationDetail timer initialization
    
    The timer variables were not being properly initialized leading to bogus
    time values sometimes being displayed.

 src/OperationDetail.cc |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/src/OperationDetail.cc b/src/OperationDetail.cc
index 4c9fa3f..e74dec7 100644
--- a/src/OperationDetail.cc
+++ b/src/OperationDetail.cc
@@ -22,22 +22,16 @@
 namespace GParted
 {
 
-OperationDetail::OperationDetail()
+OperationDetail::OperationDetail() : status( STATUS_NONE ), time_start( -1 ), time_elapsed( -1 ), fraction( -1 )
 {
-	status = STATUS_NONE; // prevent uninitialized member access
 	set_status( STATUS_NONE ) ;
-	fraction = -1 ;
-	time_elapsed = -1 ;
 }
 
-OperationDetail::OperationDetail( const Glib::ustring & description, OperationDetailStatus status, Font font )
+OperationDetail::OperationDetail( const Glib::ustring & description, OperationDetailStatus status, Font font ) :
+	status( STATUS_NONE ), time_start( -1 ), time_elapsed( -1 ), fraction( -1 )
 {
-	this ->status = STATUS_NONE; // prevent uninitialized member access
-	set_description( description, font ) ;
-	set_status( status ) ;
-
-	fraction = -1 ;
-	time_elapsed = -1 ;
+	set_description( description, font );
+	set_status( status );
 }
 
 OperationDetail::~OperationDetail()
@@ -90,7 +84,8 @@ void OperationDetail::set_status( OperationDetailStatus status )
 				break ;
 			case STATUS_ERROR:
 			case STATUS_SUCCES:
-				time_elapsed = std::time( NULL ) - time_start ;
+				if( time_start != -1 )
+					time_elapsed = std::time( NULL ) - time_start ;
 				break ;
 
 			default:



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