[gparted] Add libparted ped_file_system_resize thread to avoid blocking GUI (#737022)



commit 1561d1ae7ec1bdad5c378134fc4138f346615787
Author: Curtis Gedak <gedakc gmail com>
Date:   Tue Jul 14 13:40:56 2015 -0600

    Add libparted ped_file_system_resize thread to avoid blocking GUI (#737022)
    
    Since GParted commit 52a2a9b "Reduce threading (#685740)", released in
    GParted 0.15.0, application of operations occurs in the main thread
    running the UI, therefore long running libparted actions such as
    resizing a FAT16 or FAT32 file system hang the UI for as long as it take
    to complete the operation.
    https://git.gnome.org/browse/gparted/commit/?id=52a2a9b00a32996921ace055e71d0e09fb33c5fe
    
    Though this problem exists for all libparted actions, it is particularly
    noticeable when performing a large resize of fat16/fat32/hfs/hfs+ file
    systems.
    
    To address this significant cause of an unresponsive GUI, this
    enhancement adds threading to the libparted ped_file_system_resize
    function call.
    
    Bug 737022 - UI hangs while running libparted operations such as
                 FAT16/FAT32 resizing

 include/GParted_Core.h |    3 +++
 src/GParted_Core.cc    |   22 +++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index e7e84f9..936ebf3 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -135,6 +135,9 @@ private:
        bool resize_move_filesystem_using_libparted( const Partition & partition_old,
                                                     const Partition & partition_new,
                                                     OperationDetail & operationdetail ) ;
+       void thread_lp_ped_file_system_resize( PedFileSystem * fs,
+                                              PedGeometry * lp_geom,
+                                              bool * return_value );
 #endif
        bool resize( const Partition & partition_old,
                     const Partition & partition_new,
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index e0ba987..f73682d 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2591,7 +2591,19 @@ bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & par
                                                            partition_new .sector_start,
                                                            partition_new .get_sector_length() ) ;
                                if ( lp_geom )
-                                       return_value = ped_file_system_resize( fs, lp_geom, NULL ) && commit( 
lp_disk ) ;
+                               {
+                                       // Use thread for libparted FS resize call to avoid blocking GUI
+                                       Glib::Thread::create( sigc::bind<PedFileSystem *, PedGeometry *, bool 
*>(
+                                                                 sigc::mem_fun( *this, 
&GParted_Core::thread_lp_ped_file_system_resize ),
+                                                                 fs,
+                                                                 lp_geom,
+                                                                 &return_value ),
+                                                             false );
+                                       Gtk::Main::run();
+
+                                       if ( return_value )
+                                               commit( lp_disk ) ;
+                               }
 
                                ped_file_system_close( fs );
                        }
@@ -2602,6 +2614,14 @@ bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & par
 
        return return_value ;
 }
+
+void GParted_Core::thread_lp_ped_file_system_resize( PedFileSystem * fs,
+                                                     PedGeometry * lp_geom,
+                                                     bool * return_value )
+{
+       *return_value = ped_file_system_resize( fs, lp_geom, NULL );
+       g_idle_add( (GSourceFunc)_mainquit, NULL );
+}
 #endif
 
 bool GParted_Core::resize( const Partition & partition_old, 


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