UI: Always prompt when updates are available

The current updater code won't prompt the user if an output is active or
if game capture is in use. These are both fairly common situations to be
in as soon as OBS starts up - for example, the NDI and VirtualCam
plugins both start outputs automatically, and a game capture source will
hook if the game is open.

It should be fairly obvious to a user that OBS will be closed when an
update is installed. Given the low frequency of game capture updates,
the risk of an update encountering in-use files is also very low, and
the standalone updater UI already shows a prompt should this happen.
This commit is contained in:
Richard Stanway 2020-02-03 22:42:00 +01:00
parent 86d3eb3088
commit 4b9f3cb369

View File

@ -503,26 +503,6 @@ int AutoUpdateThread::queryUpdate(bool localManualUpdate, const char *text_utf8)
return ret;
}
static bool IsFileInUse(const wstring &file)
{
WinHandle f = CreateFile(file.c_str(), GENERIC_WRITE, 0, nullptr,
OPEN_EXISTING, 0, nullptr);
if (!f.Valid()) {
int err = GetLastError();
if (err == ERROR_SHARING_VIOLATION ||
err == ERROR_LOCK_VIOLATION)
return true;
}
return false;
}
static bool IsGameCaptureInUse()
{
wstring path = L"..\\..\\data\\obs-plugins\\win-capture\\graphics-hook";
return IsFileInUse(path + L"32.dll") || IsFileInUse(path + L"64.dll");
}
void AutoUpdateThread::run()
try {
long responseCode;
@ -546,29 +526,6 @@ try {
BPtr<char> manifestPath =
GetConfigPathPtr("obs-studio\\updates\\manifest.json");
auto ActiveOrGameCaptureLocked = [this]() {
if (obs_video_active()) {
if (manualUpdate)
info(QTStr("Updater.Running.Title"),
QTStr("Updater.Running.Text"));
return true;
}
if (IsGameCaptureInUse()) {
if (manualUpdate)
info(QTStr("Updater.GameCaptureActive.Title"),
QTStr("Updater.GameCaptureActive.Text"));
return true;
}
return false;
};
/* ----------------------------------- *
* warn if running or gc locked */
if (ActiveOrGameCaptureLocked())
return;
/* ----------------------------------- *
* create signature provider */
@ -665,12 +622,6 @@ try {
if (!manualUpdate && updateVer == skipUpdateVer)
return;
/* ----------------------------------- *
* warn again if running or gc locked */
if (ActiveOrGameCaptureLocked())
return;
/* ----------------------------------- *
* fetch updater module */