[vlc-commits] macosx: renderer: keep selected item

Thomas Guillem git at videolan.org
Tue Feb 6 19:33:19 CET 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Feb  6 16:30:39 2018 +0100| [1bd85d06b84bbcd38c8fd09e655e24ed69a839d1] | committer: Jean-Baptiste Kempf

macosx: renderer: keep selected item

Don't remove the selected item when the discoverer is closed (and don't stop
the CC session).

(cherry picked from commit 35e7089a2758aaa8b66aa865bce341860714c6d1)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=1bd85d06b84bbcd38c8fd09e655e24ed69a839d1
---

 modules/gui/macosx/VLCRendererMenuController.m | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/modules/gui/macosx/VLCRendererMenuController.m b/modules/gui/macosx/VLCRendererMenuController.m
index 411a5b9125..16514122f6 100644
--- a/modules/gui/macosx/VLCRendererMenuController.m
+++ b/modules/gui/macosx/VLCRendererMenuController.m
@@ -96,6 +96,17 @@
 
 - (void)addRendererItem:(VLCRendererItem *)item
 {
+    // Check if the item is already selected
+    if (_selectedItem.representedObject != nil)
+    {
+        VLCRendererItem *selected_rd_item = _selectedItem.representedObject;
+        if ([selected_rd_item.identifier isEqualToString:item.identifier])
+        {
+            [_selectedItem setRepresentedObject:item];
+            return;
+        }
+    }
+
     // Create a menu item
     NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:item.name
                                                       action:@selector(selectRenderer:)
@@ -110,10 +121,9 @@
     NSInteger index = [_rendererMenu indexOfItemWithRepresentedObject:item];
     if (index != NSNotFound) {
         NSMenuItem *menuItem = [_rendererMenu itemAtIndex:index];
-        if (menuItem == _selectedItem) {
-            [self selectRenderer:_rendererNoneItem];
-        }
-        [_rendererMenu removeItemAtIndex:index];
+        // Don't remove selected item
+        if (menuItem != _selectedItem)
+            [_rendererMenu removeItemAtIndex:index];
     }
 }
 



More information about the vlc-commits mailing list