Browse Source

UI: Add initialization to ensure compat between pthread and NSThread

Ensures that Cocoa knows that we intend to use multiple threads, per
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html#//apple_ref/doc/uid/10000057i-CH15-SW21
PatTheMav 3 years ago
parent
commit
c1740e3636
3 changed files with 11 additions and 0 deletions
  1. 1 0
      UI/obs-app.cpp
  2. 9 0
      UI/platform-osx.mm
  3. 1 0
      UI/platform.hpp

+ 1 - 0
UI/obs-app.cpp

@@ -2070,6 +2070,7 @@ static int run_program(fstream &logFile, int argc, char *argv[])
 
 
 #if __APPLE__
 #if __APPLE__
 	InstallNSApplicationSubclass();
 	InstallNSApplicationSubclass();
+	InstallNSThreadLocks();
 
 
 	if (!isInBundle()) {
 	if (!isInBundle()) {
 		blog(LOG_ERROR,
 		blog(LOG_ERROR,

+ 9 - 0
UI/platform-osx.mm

@@ -278,6 +278,15 @@ void TaskbarOverlaySetStatus(TaskbarOverlayStatus status)
 }
 }
 @end
 @end
 
 
+void InstallNSThreadLocks()
+{
+	[[NSThread new] start];
+
+	if ([NSThread isMultiThreaded] != 1) {
+		abort();
+	}
+}
+
 void InstallNSApplicationSubclass()
 void InstallNSApplicationSubclass()
 {
 {
 	[OBSApplication sharedApplication];
 	[OBSApplication sharedApplication];

+ 1 - 0
UI/platform.hpp

@@ -84,5 +84,6 @@ void EnableOSXVSync(bool enable);
 void EnableOSXDockIcon(bool enable);
 void EnableOSXDockIcon(bool enable);
 bool isInBundle();
 bool isInBundle();
 void InstallNSApplicationSubclass();
 void InstallNSApplicationSubclass();
+void InstallNSThreadLocks();
 void disableColorSpaceConversion(QWidget *window);
 void disableColorSpaceConversion(QWidget *window);
 #endif
 #endif