浏览代码

frontend-tools: Display dialog when changing Python version

Runtime switching of Python version is not supported.
Matt Gajownik 3 年之前
父节点
当前提交
05b6346250

+ 2 - 0
UI/frontend-plugins/frontend-tools/data/locale/en-US.ini

@@ -41,6 +41,8 @@ PythonSettings.PythonInstallPath64bit="Python Install Path (64bit)"
 PythonSettings.BrowsePythonPath="Browse Python Path"
 PythonSettings.PythonVersion="Loaded Python Version: %1"
 PythonSettings.PythonNotLoaded="Python not currently loaded"
+PythonSettings.AlreadyLoaded.Title="Python Already Loaded"
+PythonSettings.AlreadyLoaded.Message="A copy of Python %1 is already loaded. To load the newly selected Python version, please restart OBS."
 ScriptLogWindow="Script Log"
 Description="Description"
 ScriptDescriptionLink.Text="Open this link in your default web browser?"

+ 17 - 1
UI/frontend-plugins/frontend-tools/scripts.cpp

@@ -470,8 +470,24 @@ void ScriptsTool::on_pythonPathBrowse_clicked()
 
 	ui->pythonPath->setText(newPath);
 
-	if (obs_scripting_python_loaded())
+	bool loaded = obs_scripting_python_loaded();
+
+	if (loaded && !newPath.isEmpty() && curPath.compare(newPath) != 0) {
+		char version[8];
+		obs_scripting_python_version(version, sizeof(version));
+		QString message =
+			QString(obs_module_text(
+					"PythonSettings.AlreadyLoaded.Message"))
+				.arg(version);
+		OBSMessageBox::information(
+			this,
+			obs_module_text("PythonSettings.AlreadyLoaded.Title"),
+			message);
 		return;
+	} else if (loaded) {
+		return;
+	}
+
 	if (!obs_scripting_load_python(path))
 		return;