Skip to content

Commit

Permalink
Merge #2602 Show correct error messages after cancelling
Browse files Browse the repository at this point in the history
  • Loading branch information
politas committed Dec 15, 2018
2 parents 038e886 + 921a0fc commit 510e77d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ All notable changes to this project will be documented in this file.
- [GUI] Suppress wrapping of status bar in Mono (#2607 by: HebaruSan; reviewed: politas)
- [GUI] Remove unnecessary parameter in Configuration methods (#2608 by: DasSkelett; reviewed: HebaruSan)
- [GUI] Revert unintentional tray icon change from #2587 (#2609 by: HebaruSan; reviewed: politas)
- [GUI] Show correct error messages after canceling (un)installations/upgrades (#2602 by: DasSkelett; reviewed: HebaruSan)

## v1.25.4
## v1.25.4 Kennedy

### Features

Expand Down
54 changes: 40 additions & 14 deletions GUI/MainInstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,44 @@ private void InstallMods(object sender, DoWorkEventArgs e) // this probably need
installCanceled = true;
};

// checks if all actions were successfull
bool processSuccessful = false;
bool resolvedAllProvidedMods = false;
// uninstall/installs/upgrades until every list is empty
// if the queue is NOT empty, resolvedAllProvidedMods is set to false until the action is done
while (!resolvedAllProvidedMods)
{
try
{
e.Result = new KeyValuePair<bool, ModChanges>(false, opts.Key);
if (!installCanceled && toUninstall.Count > 0)
if (toUninstall.Count > 0)
{
installer.UninstallList(toUninstall);
processSuccessful = false;
if (!installCanceled)
{
installer.UninstallList(toUninstall);
processSuccessful = true;
}
}
if (!installCanceled && toUpgrade.Count > 0)
if (toUpgrade.Count > 0)
{
installer.Upgrade(toUpgrade, downloader);
processSuccessful = false;
if (!installCanceled)
{
installer.Upgrade(toUpgrade, downloader);
processSuccessful = true;
}
}
if (!installCanceled && toInstall.Count > 0)
if (toInstall.Count > 0)
{
installer.InstallList(toInstall, opts.Value, downloader);
processSuccessful = false;
if (!installCanceled)
{
installer.InstallList(toInstall, opts.Value, downloader);
processSuccessful = true;
}
}
e.Result = new KeyValuePair<bool, ModChanges>(!installCanceled, opts.Key);
e.Result = new KeyValuePair<bool, ModChanges>(processSuccessful, opts.Key);
if (installCanceled)
{
return;
Expand Down Expand Up @@ -327,7 +346,7 @@ private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e)

tabController.SetTabLock(false);

if (result.Key)
if (result.Key && !installCanceled)
{
// Rebuilds the list of GUIMods
UpdateModsList(false, result.Value);
Expand All @@ -347,16 +366,23 @@ private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e)
RetryCurrentActionButton.Visible = false;
UpdateChangesDialog(null, installWorker);
}
else if(installCanceled)
{
// User cancelled the installation
// Rebuilds the list of GUIMods
UpdateModsList(false, result.Value);
UpdateChangesDialog(null, installWorker);
if (result.Key) {
FailWaitDialog("Cancellation to late, process complete!", "User canceled the process manually, but all mods already (un)installed/upgraded.", "Process complete!", result.Key);
} else {
FailWaitDialog("Process canceled by user!", "User canceled the process manually!", "(Un)Install/Upgrade canceled!", result.Key);
}
}
else
{
// There was an error
// Stay on the log dialog and re-apply the user's change set to allow retry
AddStatusMessage("Error!");
SetDescription("An error occurred, check the log for information");
FailWaitDialog("Error during installation!", "An unknown error occurred, please try again!", "Installation failed!", result.Key);
UpdateChangesDialog(result.Value, installWorker);
RetryCurrentActionButton.Visible = true;
Util.Invoke(DialogProgressBar, () => DialogProgressBar.Style = ProgressBarStyle.Continuous);
Util.Invoke(DialogProgressBar, () => DialogProgressBar.Value = 0);
}

Util.Invoke(this, () => Enabled = true);
Expand Down
25 changes: 24 additions & 1 deletion GUI/MainWait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,30 @@ public void HideWaitDialog(bool success)
});
}

/// <summary>
/// Stay on log page and reset StatusProgress
/// </summary>
/// <param name="statusMsg">Message for the lower status bar</param>
/// <param name="logMsg">Message to display on WaitDialog-Log (not the real log!)</param>
/// <param name="description">Message displayed above the DialogProgress bar</param>
public void FailWaitDialog(string statusMsg, string logMsg, string description, bool success)
{
Util.Invoke(statusStrip1, () => {
StatusProgress.Visible = false;
AddStatusMessage(statusMsg);
});
Util.Invoke(WaitTabPage, () => {
RecreateDialogs();
RetryCurrentActionButton.Visible = !success;
CancelCurrentActionButton.Enabled = false;
SetProgress(100);
});
tabController.HideTab("ChangesetTabPage");
AddLogMessage(logMsg);
SetDescription(description);
ApplyToolButton.Enabled = !success;
}

public void SetProgress(int progress)
{
if (progress < 0)
Expand Down Expand Up @@ -129,7 +153,6 @@ private void CancelCurrentActionButton_Click(object sender, EventArgs e)
{
CancelCurrentActionButton.Enabled = false;
});
HideWaitDialog(true);
}

}
Expand Down

0 comments on commit 510e77d

Please sign in to comment.