[gparted] Prevent the UI hanging while gpart data rescue is running (#772123)



commit aeebee9c12442d104b1ecb0e94ba41ec36c0c4e6
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Wed Sep 28 10:38:50 2016 +0100

    Prevent the UI hanging while gpart data rescue is running (#772123)
    
    Running Device > Attempt Data Rescue... hangs the GParted UI for as long
    as gpart takes to scan the whole disk device looking for file system
    signatures.
    
    Originally when gpart support was added by commit [1] a separate thread
    was created to run gpart.  Then most threading was removed by commit [2]
    which left gpart running in the main thread blocking the UI.
    
    [1] ef37bdb7de1bbdc145aa40ae6e66a88e0e3e5ae9
        Added support to lost data recovery using gpart
    
    [2] 52a2a9b00a32996921ace055e71d0e09fb33c5fe
        Reduce threading (#685740)
    
    guess_partition_table() hand codes using Glib to run the gpart command
    asynchronously reading standard output, but it just doesn't run the Gtk
    main loop to process events, hence the UI hangs.  Instead just use
    Utils::execute_command() which handles everything already.  It runs the
    commands asynchronously, reading output and if being run in the main
    thread also calls the Gtk main loop to keep the UI responsive.
    
    Bug 772123 - GParted is unresponsive while gpart is running

 src/GParted_Core.cc |   34 +++-------------------------------
 1 files changed, 3 insertions(+), 31 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index c1df588..0fabff4 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -386,37 +386,9 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
 // runs gpart on the specified parameter
 void GParted_Core::guess_partition_table(const Device & device, Glib::ustring &buff)
 {
-       int pid, stdoutput, stderror;
-       std::vector<std::string> argvproc, envpproc;
-       gunichar tmp;
-
-       //Get the char string of the sector_size
-       std::ostringstream ssIn;
-    ssIn << device.sector_size;
-    Glib::ustring str_ssize = ssIn.str();
-
-       //Build the command line
-       argvproc.push_back("gpart");
-       argvproc.push_back(device.get_path());
-       argvproc.push_back("-s");
-       argvproc.push_back(str_ssize);
-
-       envpproc .push_back( "LC_ALL=C" ) ;
-       envpproc .push_back( "PATH=" + Glib::getenv( "PATH" ) ) ;
-
-       Glib::spawn_async_with_pipes(Glib::get_current_dir(), argvproc,
-               envpproc, Glib::SPAWN_SEARCH_PATH, sigc::slot<void>(),
-               &pid, NULL, &stdoutput, &stderror);
-
-       this->iocOutput=Glib::IOChannel::create_from_fd(stdoutput);
-
-       while(this->iocOutput->read(tmp)==Glib::IO_STATUS_NORMAL)
-       {
-               buff+=tmp;
-       }
-       this->iocOutput->close();
-
-       return;
+       Glib::ustring error;
+       Glib::ustring cmd = "gpart -s " + Utils::num_to_str( device.sector_size ) + " " + device.get_path();
+       Utils::execute_command( cmd, buff, error, true );
 }
 
 void GParted_Core::set_thread_status_message( Glib::ustring msg )


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