Commit 91d1ffb9 authored by Melroy van den Berg's avatar Melroy van den Berg

Fix async issue #16 as well as async issue during bottle creation. Fixing...

Fix async issue #16 as well as async issue during bottle creation. Fixing building the folder path to C: letter cross-platform.
parent e435cf87
Pipeline #1759 passed with stages
in 3 minutes and 38 seconds
......@@ -50,6 +50,7 @@ public:
static void RunProgram(string prefix_path, string program, bool enable_tracing, bool give_error);
static void RunProgramUnderWine(string prefix_path, string program, bool enable_tracing, bool is_msi_file);
static void RunProgramWithFinishCallback(string prefix_path, string program, bool enable_tracing, bool give_error, bool is_msi_file, Glib::Dispatcher* finishSignal);
static void WaitUntilWineserverIsTerminated(const string prefix_path);
static string GetWineExecutableLocation();
static string GetWinetricksLocation();
static string GetWineVersion();
......
......@@ -234,17 +234,10 @@ void BottleManager::NewBottle(
// TODO: Finally add name to WineGUI config file
}
// TODO: All calls above are blocking calls, still sometimes the registery files are not yet updated on disk?
//
// Before we send a finish signal, wait until the status is OK, with a time-out.
// Especially needed when the user create a default Windows OS Wine bottle, with no additional settings
int time_out_counter = 0;
while(!Helper::GetBottleStatus(wine_prefix) && time_out_counter < 20)
{
std::this_thread::sleep_for(std::chrono::milliseconds(500));
++time_out_counter;
}
// Wait until wineserver terminates
Helper::WaitUntilWineserverIsTerminated(wine_prefix);
// Trigger finish signal!
caller->SignalBottleCreated();
}
......
......@@ -177,6 +177,7 @@ void Helper::RunProgramUnderWine(string prefix_path, string program, bool enable
/**
* \brief Run a Windows program under Wine (run this method async)
* This method will really wait until the wineserver is down.
* \param[in] prefix_path - The path to bottle wine
* \param[in] program - Program/executable that will be executed
* \param[in] enable_tracing - Enable debugging tracing to file
......@@ -210,11 +211,26 @@ void Helper::RunProgramWithFinishCallback(string prefix_path,
Exec(("WINEPREFIX=\"" + prefix_path + "\" " + program).c_str());
}
// Blocking wait until wineserver is terminated (before we can look in the reg files for example)
Helper::WaitUntilWineserverIsTerminated(prefix_path);
// When the server is termined (or timed-out), finally fire the finish signal
if (finishSignal != nullptr) {
finishSignal->emit();
}
}
/**
* \brief Blocking wait (with timeout functionality) until wineserver is terminated.
*/
void Helper::WaitUntilWineserverIsTerminated(const string prefix_path)
{
string exitCode = Exec(("WINEPREFIX=\"" + prefix_path + "\" timeout 60 wineserver -w; echo $?").c_str());
if (exitCode == "124") {
g_warning("Time-out of wineserver wait command triggered (wineserver is still running..)");
}
}
/**
* \brief Retrieve the Wine executable (full path if applicable)
* \return Wine binary location
......@@ -550,29 +566,26 @@ string Helper::GetLastWineUpdated(const string prefix_path)
}
/**
* \brief Get Bottle Status (is Bottle ready or not)
* \brief Get Bottle Status, to validate some bear minimal Wine stuff
* Hint: use WaitUntilWineserverIsTerminated, if you want to wait until the Bottle is fully created
* \param[in] prefix_path - Bottle prefix
* TODO: Maybe do not make this call blocking but async, using a thread & dispatcher signal
* \return True if everything is OK, otherwise false
*/
bool Helper::GetBottleStatus(const string prefix_path)
{
// First check if directory exists at all (otherwise any wine command will create a new bottle)
// And check if system.reg is present (important Wine file)
// And finally if we can read-out the Windows OS version
if (Helper::DirExists(prefix_path) &&
Helper::FileExists(Glib::build_filename(prefix_path, SYSTEM_REG))) {
try
{
// Check if some directories exists, and system registery file,
// and finally, if we can read-out the Windows OS version without errors
if (Helper::DirExists(prefix_path) &&
Helper::DirExists(Glib::build_filename(prefix_path, "dosdevices")) &&
Helper::FileExists(Glib::build_filename(prefix_path, SYSTEM_REG)))
{
try {
Helper::GetWindowsOSVersion(prefix_path);
return true;
} catch (const std::runtime_error& error){
// Not good!
return false;
}
// TODO: Wine exec takes quite long, execute that in a seperate thread (don't block UI).
// TODO: test the explorer /desktop=root part of the command
//string result = Exec(("WINEPREFIX=\"" + prefix_path + "\" " + Helper::GetWineExecutableLocation() + " explorer /desktop=root cmd /Q /C ver").c_str());
} else {
return false;
}
......@@ -586,7 +599,7 @@ bool Helper::GetBottleStatus(const string prefix_path)
string Helper::GetCLetterDrive(const string prefix_path)
{
// Determ C location
string c_drive_location = Glib::build_filename(prefix_path, "/dosdevices/c:/");
string c_drive_location = Glib::build_filename(prefix_path, "dosdevices", "c:");
if (Helper::DirExists(prefix_path) &&
Helper::DirExists(c_drive_location)) {
return c_drive_location;
......
......@@ -102,8 +102,7 @@ void SignalDispatcher::DispatchSignals()
manager.resetActiveBottle.connect(sigc::mem_fun(settingsWindow, &SettingsWindow::ResetActiveBottle));
manager.resetActiveBottle.connect(sigc::mem_fun(*mainWindow, &MainWindow::ResetDetailedInfo));
// Package install finished (in settings window), close the busy dialog & refresh the settings window
manager.finishedPackageInstall.connect(sigc::mem_fun(*mainWindow, &MainWindow::CloseBusyDialog));
// TODO BUG: UpdateInstalled is called too soon, file on disks (registery) are not yet updated? This is the same problem during Bottle creation (windows version/virtual desktop)!
manager.finishedPackageInstall.connect(sigc::mem_fun(*mainWindow, &MainWindow::CloseBusyDialog));
manager.finishedPackageInstall.connect(sigc::mem_fun(settingsWindow, &SettingsWindow::UpdateInstalled));
// Menu / Toolbar actions
......
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