[vlc-commits] [Git][videolan/vlc][master] macosx: Fix a bug preventing VLC from launching

David (@dfuhrmann) gitlab at videolan.org
Sat Sep 18 10:50:41 UTC 2021



David pushed to branch master at VideoLAN / VLC


Commits:
8cb3f814 by Samuel Bassaly at 2021-09-18T10:38:53+00:00
macosx: Fix a bug preventing VLC from launching

When the defaults key VideoEffectApplyProfileOnStartup is set to true,
the VLCVideoEffectsWindowController was initialized in a way that caused
the VLCMain's sharedInstance method to be called recursively on launch.

This caused the app to crash, in the VLCMain's init.

The method [VLCVideoEffectsWindowController resetValues] was the source.
In this fix, call this method with dispatch async, to get the
sharedInstance after it is fully intitalized.
This is similar to what is done in VLCAudioEffectsWindowController.

Closes #24746.

- - - - -


1 changed file:

- modules/gui/macosx/panels/VLCVideoEffectsWindowController.m


Changes:

=====================================
modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
=====================================
@@ -79,26 +79,27 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
 {
     self = [super initWithWindowNibName:@"VideoEffects"];
     if (self) {
-        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
-        [notificationCenter addObserver:self
-                               selector:@selector(updateCocoaWindowLevel:)
-                                   name:VLCWindowShouldUpdateLevel
-                                 object:nil];
-        [notificationCenter addObserver:self
-                               selector:@selector(saveCurrentProfileAtTerminate:)
-                                   name:NSApplicationWillTerminateNotification
-                                 object:nil];
-
-        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-        if ([defaults boolForKey:@"VideoEffectApplyProfileOnStartup"]) {
-            // This does not reset the UI (which does not exist yet), but it initalizes needed playlist vars
-            [self resetValues];
-
-            [self loadProfile];
-        } else {
-            [self saveCurrentProfileIndex:0];
-        }
-
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+            [notificationCenter addObserver:self
+                                   selector:@selector(updateCocoaWindowLevel:)
+                                       name:VLCWindowShouldUpdateLevel
+                                     object:nil];
+            [notificationCenter addObserver:self
+                                   selector:@selector(saveCurrentProfileAtTerminate:)
+                                       name:NSApplicationWillTerminateNotification
+                                     object:nil];
+
+            NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+            if ([defaults boolForKey:@"VideoEffectApplyProfileOnStartup"]) {
+                // This does not reset the UI (which does not exist yet), but it initalizes needed playlist vars
+                [self resetValues];
+
+                [self loadProfile];
+            } else {
+                [self saveCurrentProfileIndex:0];
+            }
+        });
     }
 
     return self;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8cb3f81422c566ea738200f26d2c0c70bde8f9ed

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8cb3f81422c566ea738200f26d2c0c70bde8f9ed
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list