Explorar o código

UI: Add flag/file to disable built-in updater

When distributing OBS via third party platforms that have their own
update systems we want to be able to disable the OBS updater without
having to resort to having a separate build entirely.
derrod %!s(int64=5) %!d(string=hai) anos
pai
achega
30862d75ae
Modificáronse 3 ficheiros con 23 adicións e 1 borrados
  1. 17 1
      UI/obs-app.cpp
  2. 1 0
      UI/obs-app.hpp
  3. 5 0
      UI/window-basic-main.cpp

+ 17 - 1
UI/obs-app.cpp

@@ -79,6 +79,7 @@ bool opt_start_virtualcam = false;
 bool opt_minimize_tray = false;
 bool opt_minimize_tray = false;
 bool opt_allow_opengl = false;
 bool opt_allow_opengl = false;
 bool opt_always_on_top = false;
 bool opt_always_on_top = false;
+bool opt_disable_updater = false;
 string opt_starting_collection;
 string opt_starting_collection;
 string opt_starting_profile;
 string opt_starting_profile;
 string opt_starting_scene;
 string opt_starting_scene;
@@ -1424,6 +1425,11 @@ bool OBSApp::IsPortableMode()
 	return portable_mode;
 	return portable_mode;
 }
 }
 
 
+bool OBSApp::IsUpdaterDisabled()
+{
+	return opt_disable_updater;
+}
+
 #ifdef __APPLE__
 #ifdef __APPLE__
 #define INPUT_AUDIO_SOURCE "coreaudio_input_capture"
 #define INPUT_AUDIO_SOURCE "coreaudio_input_capture"
 #define OUTPUT_AUDIO_SOURCE "coreaudio_output_capture"
 #define OUTPUT_AUDIO_SOURCE "coreaudio_output_capture"
@@ -2450,6 +2456,9 @@ int main(int argc, char *argv[])
 		} else if (arg_is(argv[i], "--allow-opengl", nullptr)) {
 		} else if (arg_is(argv[i], "--allow-opengl", nullptr)) {
 			opt_allow_opengl = true;
 			opt_allow_opengl = true;
 
 
+		} else if (arg_is(argv[i], "--disable-updater", nullptr)) {
+			opt_disable_updater = true;
+
 		} else if (arg_is(argv[i], "--help", "-h")) {
 		} else if (arg_is(argv[i], "--help", "-h")) {
 			std::string help =
 			std::string help =
 				"--help, -h: Get list of available commands.\n\n"
 				"--help, -h: Get list of available commands.\n\n"
@@ -2467,7 +2476,8 @@ int main(int argc, char *argv[])
 				"--multi, -m: Don't warn when launching multiple instances.\n\n"
 				"--multi, -m: Don't warn when launching multiple instances.\n\n"
 				"--verbose: Make log more verbose.\n"
 				"--verbose: Make log more verbose.\n"
 				"--always-on-top: Start in 'always on top' mode.\n\n"
 				"--always-on-top: Start in 'always on top' mode.\n\n"
-				"--unfiltered_log: Make log unfiltered.\n\n";
+				"--unfiltered_log: Make log unfiltered.\n\n"
+				"--disable-updater: Disable built-in updater (Windows/Mac only)\n\n";
 
 
 #ifdef _WIN32
 #ifdef _WIN32
 			MessageBoxA(NULL, help.c_str(), "Help",
 			MessageBoxA(NULL, help.c_str(), "Help",
@@ -2493,6 +2503,12 @@ int main(int argc, char *argv[])
 			os_file_exists(BASE_PATH "/portable_mode.txt") ||
 			os_file_exists(BASE_PATH "/portable_mode.txt") ||
 			os_file_exists(BASE_PATH "/obs_portable_mode.txt");
 			os_file_exists(BASE_PATH "/obs_portable_mode.txt");
 	}
 	}
+
+	if (!opt_disable_updater) {
+		opt_disable_updater =
+			os_file_exists(BASE_PATH "/disable_updater") ||
+			os_file_exists(BASE_PATH "/disable_updater.txt");
+	}
 #endif
 #endif
 
 
 	upgrade_settings();
 	upgrade_settings();

+ 1 - 0
UI/obs-app.hpp

@@ -144,6 +144,7 @@ public:
 
 
 	std::string GetVersionString() const;
 	std::string GetVersionString() const;
 	bool IsPortableMode();
 	bool IsPortableMode();
+	bool IsUpdaterDisabled();
 
 
 	const char *InputAudioSource() const;
 	const char *InputAudioSource() const;
 	const char *OutputAudioSource() const;
 	const char *OutputAudioSource() const;

+ 5 - 0
UI/window-basic-main.cpp

@@ -1894,6 +1894,9 @@ void OBSBasic::OBSInit()
 	ui->actionUploadLastCrashLog = nullptr;
 	ui->actionUploadLastCrashLog = nullptr;
 	ui->menuCrashLogs = nullptr;
 	ui->menuCrashLogs = nullptr;
 	ui->actionCheckForUpdates = nullptr;
 	ui->actionCheckForUpdates = nullptr;
+#elif _WIN32 || __APPLE__
+	if (App()->IsUpdaterDisabled())
+		ui->actionCheckForUpdates->setEnabled(false);
 #endif
 #endif
 
 
 	OnFirstLoad();
 	OnFirstLoad();
@@ -3248,6 +3251,8 @@ void trigger_sparkle_update();
 
 
 void OBSBasic::TimedCheckForUpdates()
 void OBSBasic::TimedCheckForUpdates()
 {
 {
+	if (App()->IsUpdaterDisabled())
+		return;
 	if (!config_get_bool(App()->GlobalConfig(), "General",
 	if (!config_get_bool(App()->GlobalConfig(), "General",
 			     "EnableAutoUpdates"))
 			     "EnableAutoUpdates"))
 		return;
 		return;