[gparted] Ensure no pending operations before creating partition table (#583896)



commit 83381f85f13a0f3421a3b0eee98e498961db6119
Author: Curtis Gedak <gedakc gmail com>
Date:   Sun Oct 25 14:33:36 2009 -0600

    Ensure no pending operations before creating partition table (#583896)
    
    This fixes a situation where GParted would crash if a user queued
    up some operations, created a new partition table, and then
    applied the operations.

 src/Win_GParted.cc |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index bb1cc95..2d0b0e2 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1880,6 +1880,34 @@ void Win_GParted::activate_mount_partition( unsigned int index )
 
 void Win_GParted::activate_disklabel()
 {
+	//If there are pending operations then warn the user that these
+	//  operations must either be applied or cleared before creating
+	//  a new partition table.
+	if ( operations .size() )
+	{
+		Glib::ustring tmp_msg =
+		    String::ucompose( ngettext( "%1 operation is currently pending."
+		                              , "%1 operations are currently pending."
+		                              , operations .size()
+		                              )
+		                    , operations .size()
+		                    ) ;
+		Gtk::MessageDialog dialog( *this
+		                         , tmp_msg
+		                         , false
+		                         , Gtk::MESSAGE_INFO
+		                         , Gtk::BUTTONS_OK
+		                         , true
+		                         ) ;
+		tmp_msg  = _( "A new partition table cannot be created when there are pending operations." ) ;
+		tmp_msg += "\n" ;
+		tmp_msg += _( "Use the Edit menu to either clear or apply all operations before creating a new partition table." ) ;
+		dialog .set_secondary_text( tmp_msg ) ;
+		dialog .run() ;
+		return ;
+	}
+
+	//Display dialog for creating a new partition table.
 	Dialog_Disklabel dialog( devices[ current_device ] .get_path(), gparted_core .get_disklabeltypes() ) ;
 	dialog .set_transient_for( *this );
 



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