Commit 0150650e authored by David Fuhrmann's avatar David Fuhrmann

macosx: fix UI freeze when large amount of playlist items are added at once

This happened when selecting radio discovery, for instance.
Probably also fixes #7516.
parent 613bbb83
......@@ -149,11 +149,13 @@ struct intf_sys_t
/* iTunes play/pause support */
BOOL b_has_itunes_paused;
NSTimer *o_itunes_play_timer;
BOOL b_playlist_updated_selector_in_queue;
}
@property (readonly) VLCVoutWindowController* voutController;
@property (readonly) BOOL nativeFullscreenMode;
@property (nonatomic, readwrite) BOOL playlistUpdatedSelectorInQueue;
+ (VLCMain *)sharedInstance;
- (intf_thread_t *)intf;
......
......@@ -420,7 +420,17 @@ static int PlaylistUpdated(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param)
{
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
[[VLCMain sharedInstance] performSelectorOnMainThread:@selector(playlistUpdated) withObject:nil waitUntilDone:NO];
/* Avoid event queue flooding with playlistUpdated selectors, leading to UI freezes.
* Therefore, only enqueue if no selector already enqueued.
*/
VLCMain *o_main = [VLCMain sharedInstance];
@synchronized(o_main) {
if(![o_main playlistUpdatedSelectorInQueue]) {
[o_main setPlaylistUpdatedSelectorInQueue:YES];
[o_main performSelectorOnMainThread:@selector(playlistUpdated) withObject:nil waitUntilDone:NO];
}
}
[o_pool release];
return VLC_SUCCESS;
......@@ -591,6 +601,7 @@ audio_output_t *getAout(void)
@synthesize voutController=o_vout_controller;
@synthesize nativeFullscreenMode=b_nativeFullscreenMode;
@synthesize playlistUpdatedSelectorInQueue=b_playlist_updated_selector_in_queue;
#pragma mark -
#pragma mark Initialization
......@@ -1342,6 +1353,10 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)playlistUpdated
{
@synchronized(self) {
b_playlist_updated_selector_in_queue = NO;
}
[self playbackStatusUpdated];
[o_playlist playlistUpdated];
[o_mainwindow updateWindow];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment