Преглед изворни кода

UI: Add warning on startup for running in Wine

Rodney пре 3 година
родитељ
комит
b7a24d54c9
4 измењених фајлова са 44 додато и 3 уклоњено
  1. 3 0
      UI/data/locale/en-US.ini
  2. 20 3
      UI/obs-app.cpp
  3. 20 0
      UI/platform-windows.cpp
  4. 1 0
      UI/platform.hpp

+ 3 - 0
UI/data/locale/en-US.ini

@@ -109,6 +109,9 @@ AlreadyRunning.LaunchAnyway="Launch Anyway"
 ChromeOS.Title="Unsupported Platform"
 ChromeOS.Text="OBS appears to be running inside a ChromeOS container. This platform is unsupported"
 
+Wine.Title="Wine detected"
+Wine.Text="Running OBS in Wine is unsupported, and many features such as capture or device sources will not work or only in limited capacity.<br><br>It is recommended to run a native version of OBS instead, for example <a href='https://flathub.org/apps/details/com.obsproject.Studio'>our Flatpak version</a> or your operating system's packages."
+
 # warning when closing docks. it's frustrating that we actually need this.
 DockCloseWarning.Title="Closing Dockable Window"
 DockCloseWarning.Text="You just closed a dockable window. If you'd like to show it again, use the Docks menu on the menu bar."

+ 20 - 3
UI/obs-app.cpp

@@ -2156,16 +2156,33 @@ static int run_program(fstream &logFile, int argc, char *argv[])
 		}
 #endif
 
+		if (!created_log) {
+			create_log_file(logFile);
+			created_log = true;
+		}
+
 #ifdef __APPLE__
 		bool rosettaTranslated = ProcessIsRosettaTranslated();
 		blog(LOG_INFO, "Rosetta translation used: %s",
 		     rosettaTranslated ? "true" : "false");
 #endif
 
-		if (!created_log) {
-			create_log_file(logFile);
-			created_log = true;
+#ifdef _WIN32
+		if (IsRunningOnWine()) {
+			QMessageBox mb(QMessageBox::Question,
+				       QTStr("Wine.Title"), QTStr("Wine.Text"));
+			mb.setTextFormat(Qt::RichText);
+			mb.addButton(QTStr("AlreadyRunning.LaunchAnyway"),
+				     QMessageBox::AcceptRole);
+			QPushButton *closeButton =
+				mb.addButton(QMessageBox::Close);
+			mb.setDefaultButton(closeButton);
+
+			mb.exec();
+			if (mb.clickedButton() == closeButton)
+				return 0;
 		}
+#endif
 
 		if (argc > 1) {
 			stringstream stor;

+ 20 - 0
UI/platform-windows.cpp

@@ -449,3 +449,23 @@ QString GetMonitorName(const QString &id)
 
 	return QString::fromWCharArray(target.monitorFriendlyDeviceName);
 }
+
+/* Based on https://www.winehq.org/pipermail/wine-devel/2008-September/069387.html */
+typedef const char *(CDECL *WINEGETVERSION)(void);
+bool IsRunningOnWine()
+{
+	WINEGETVERSION func;
+	HMODULE nt;
+
+	nt = GetModuleHandleW(L"ntdll");
+	if (!nt)
+		return false;
+
+	func = (WINEGETVERSION)GetProcAddress(nt, "wine_get_version");
+	if (func) {
+		blog(LOG_WARNING, "Running on Wine version \"%s\"", func());
+		return true;
+	}
+
+	return false;
+}

+ 1 - 0
UI/platform.hpp

@@ -64,6 +64,7 @@ public:
 
 RunOnceMutex GetRunOnceMutex(bool &already_running);
 QString GetMonitorName(const QString &id);
+bool IsRunningOnWine();
 #endif
 
 #ifdef __APPLE__