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
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] 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
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 )
......
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