UpdaterCommon: Remove manual UI::Stop() calls in favour of a scope guard to ensure it's called on all return paths

This commit is contained in:
Silent 2019-06-24 20:49:18 +02:00
parent 2ae409ba06
commit 3f1ba830e7
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1

View File

@ -16,6 +16,7 @@
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/HttpRequest.h"
#include "Common/ScopeGuard.h"
#include "Common/StringUtil.h"
#include "UpdaterCommon/UI.h"
@ -498,7 +499,6 @@ void FatalError(const std::string& message)
UI::SetVisible(true);
UI::Error(message);
UI::Stop();
}
std::optional<Manifest> ParseManifest(const std::string& manifest)
@ -686,6 +686,7 @@ bool RunUpdater(std::vector<std::string> args)
UI::Init();
UI::SetVisible(false);
Common::ScopeGuard ui_guard{[] { UI::Stop(); }};
Options opts = std::move(*maybe_opts);
if (opts.log_file)
@ -777,7 +778,5 @@ bool RunUpdater(std::vector<std::string> args)
UI::LaunchApplication(opts.binary_to_restart.value());
}
UI::Stop();
return true;
}