Commit aeebee9c authored by Mike Fleetwood's avatar Mike Fleetwood Committed by Curtis Gedak

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

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] ef37bdb7
    Added support to lost data recovery using gpart

[2] 52a2a9b0
    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
parent 7ea22f11
......@@ -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
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);
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 )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment