[vlc-commits] macosx: Use specific class for log messages

Marvin Scholz git at videolan.org
Wed Sep 27 03:46:12 CEST 2017


vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Wed Sep 27 03:45:56 2017 +0200| [a4a45e75e440d4c8c917d15baf7c31a63035b2d0] | committer: Marvin Scholz

macosx: Use specific class for log messages

Instead of a NSDictionary, use a dedicated class for log messages.
Not only allows this for better abstraction and reusability, it
additionally solves a problem where log messages with the same content
would be considered equal, because all keys in the dictionary were
equal, ending up in wrong selections in the table.

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

 .../package/macosx/VLC.xcodeproj/project.pbxproj   | 10 +++-
 modules/gui/macosx/Makefile.am                     |  1 +
 modules/gui/macosx/UI/LogMessageWindow.xib         | 24 +++-----
 modules/gui/macosx/VLCLogMessage.h                 | 40 +++++++++++++
 modules/gui/macosx/VLCLogMessage.m                 | 70 ++++++++++++++++++++++
 modules/gui/macosx/VLCLogWindowController.m        | 61 +++++++------------
 6 files changed, 150 insertions(+), 56 deletions(-)

diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
index 994aced22b..06b76880fb 100644
--- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
@@ -93,6 +93,7 @@
 		6BBB05DA1EEFEA29003A1019 /* VLCHUDOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBB05D91EEFEA29003A1019 /* VLCHUDOutlineView.m */; };
 		6BBB05E01EEFF165003A1019 /* VLCHUDTableCornerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBB05DF1EEFF165003A1019 /* VLCHUDTableCornerView.m */; };
 		6BBB05E31EF08181003A1019 /* VLCHUDSegmentedCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBB05E21EF08181003A1019 /* VLCHUDSegmentedCell.m */; };
+		6BBBF9851F7B257100B404CD /* VLCLogMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BBBF9841F7B257100B404CD /* VLCLogMessage.m */; };
 		6BF093F91EE0182B0049D8B0 /* VLCTimeField.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF093F81EE0182B0049D8B0 /* VLCTimeField.m */; };
 		6BF5C5011EFE03CF008A9C12 /* VLCHUDStepperCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF5C5001EFE03CF008A9C12 /* VLCHUDStepperCell.m */; };
 		6BF5C5041EFE66EF008A9C12 /* VLCHUDTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF5C5031EFE66EF008A9C12 /* VLCHUDTableView.m */; };
@@ -635,6 +636,8 @@
 		6BBBB8B11D10A994001BD9BA /* VLCRendererItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCRendererItem.m; sourceTree = "<group>"; };
 		6BBBB8B51D114628001BD9BA /* VLCRendererDiscovery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCRendererDiscovery.h; sourceTree = "<group>"; };
 		6BBBB8B61D114628001BD9BA /* VLCRendererDiscovery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCRendererDiscovery.m; sourceTree = "<group>"; };
+		6BBBF9831F7B257100B404CD /* VLCLogMessage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLogMessage.h; sourceTree = "<group>"; };
+		6BBBF9841F7B257100B404CD /* VLCLogMessage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLogMessage.m; sourceTree = "<group>"; };
 		6BCB59091DA247CD009BCA66 /* VLCFSPanelController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCFSPanelController.h; sourceTree = "<group>"; };
 		6BCB590A1DA247CD009BCA66 /* VLCFSPanelController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCFSPanelController.m; sourceTree = "<group>"; };
 		6BF093F71EE0182B0049D8B0 /* VLCTimeField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCTimeField.h; sourceTree = "<group>"; };
@@ -850,6 +853,8 @@
 				CC4A33210F8CB017000FC4A7 /* VLCCoreDialogProvider.m */,
 				CC448A6013B68A0B009F72E0 /* VLCCoreInteraction.h */,
 				CC448A6113B68A0B009F72E0 /* VLCCoreInteraction.m */,
+				6BBBF9831F7B257100B404CD /* VLCLogMessage.h */,
+				6BBBF9841F7B257100B404CD /* VLCLogMessage.m */,
 				7D8BB0B318302AC000FAE9B7 /* VLCLogWindowController.h */,
 				7D8BB0B418302AC000FAE9B7 /* VLCLogWindowController.m */,
 				1C39ABBC1DA9AB9B00FE052A /* VLCDocumentController.h */,
@@ -1699,7 +1704,7 @@
 					};
 				};
 			};
-			buildConfigurationList = C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "vlc" */;
+			buildConfigurationList = C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "VLC" */;
 			compatibilityVersion = "Xcode 3.2";
 			developmentRegion = English;
 			hasScannedForEncodings = 1;
@@ -1754,6 +1759,7 @@
 				1C3113941E508C6900D4DD76 /* VLCAddonsWindowController.m in Sources */,
 				1C3113961E508C6900D4DD76 /* applescript.m in Sources */,
 				1C3113981E508C6900D4DD76 /* VLCAudioEffectsWindowController.m in Sources */,
+				6BBBF9851F7B257100B404CD /* VLCLogMessage.m in Sources */,
 				1C31139A1E508C6900D4DD76 /* VLCBookmarksWindowController.m in Sources */,
 				6B0AB0F01F1AC8B3003A1B4E /* VLCSlider.m in Sources */,
 				6BF5C5041EFE66EF008A9C12 /* VLCHUDTableView.m in Sources */,
@@ -2018,7 +2024,7 @@
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Default;
 		};
-		C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "vlc" */ = {
+		C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "VLC" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
 				C2F2A6EB09588F1B00018C74 /* Development */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index f0079544b0..89e4f9aa45 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -71,6 +71,7 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/VLCAudioEffectsWindowController.h gui/macosx/VLCAudioEffectsWindowController.m \
 	gui/macosx/VLCBookmarksWindowController.h gui/macosx/VLCBookmarksWindowController.m \
 	gui/macosx/VLCCoreDialogProvider.h gui/macosx/VLCCoreDialogProvider.m \
+	gui/macosx/VLCLogMessage.h gui/macosx/VLCLogMessage.m \
 	gui/macosx/VLCLogWindowController.h gui/macosx/VLCLogWindowController.m \
 	gui/macosx/VLCHUDSliderCell.h gui/macosx/VLCHUDSliderCell.m \
 	gui/macosx/VLCHUDButtonCell.h gui/macosx/VLCHUDButtonCell.m \
diff --git a/modules/gui/macosx/UI/LogMessageWindow.xib b/modules/gui/macosx/UI/LogMessageWindow.xib
index 77edd13488..64baa56c7f 100644
--- a/modules/gui/macosx/UI/LogMessageWindow.xib
+++ b/modules/gui/macosx/UI/LogMessageWindow.xib
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16G24b" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="17A365" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment version="1070" identifier="macosx"/>
         <development version="7000" identifier="xcode"/>
@@ -48,7 +48,7 @@
                                                     <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                     <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
                                                     <tableColumns>
-                                                        <tableColumn width="60" minWidth="40" maxWidth="1000" id="1UD-vH-uqq">
+                                                        <tableColumn identifier="" width="60" minWidth="40" maxWidth="1000" id="1UD-vH-uqq">
                                                             <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Type">
                                                                 <font key="font" metaFont="smallSystem"/>
                                                                 <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -73,7 +73,7 @@
                                                                                 <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                                                                             </textFieldCell>
                                                                             <connections>
-                                                                                <binding destination="9bi-ti-5pD" name="value" keyPath="objectValue.type" id="K3E-xf-XY7"/>
+                                                                                <binding destination="9bi-ti-5pD" name="value" keyPath="objectValue.typeName" id="jag-ra-88G"/>
                                                                             </connections>
                                                                         </textField>
                                                                     </subviews>
@@ -88,7 +88,7 @@
                                                                 </tableCellView>
                                                             </prototypeCellViews>
                                                         </tableColumn>
-                                                        <tableColumn width="90" minWidth="40" maxWidth="1000" id="ybR-8n-0YS">
+                                                        <tableColumn identifier="" width="90" minWidth="40" maxWidth="1000" id="ybR-8n-0YS">
                                                             <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Component">
                                                                 <font key="font" metaFont="smallSystem"/>
                                                                 <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -145,7 +145,7 @@
                                                                     <rect key="frame" x="157" y="1" width="321" height="17"/>
                                                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                                     <subviews>
-                                                                        <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsExpansionToolTips="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hdT-qU-xRy">
+                                                                        <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" misplaced="YES" allowsExpansionToolTips="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hdT-qU-xRy">
                                                                             <rect key="frame" x="0.0" y="-9" width="321" height="35"/>
                                                                             <textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" placeholderString="" usesSingleLineMode="YES" id="ed5-yc-Kp5">
                                                                                 <font key="font" metaFont="system"/>
@@ -212,7 +212,7 @@ It can even span multiple lines</string>
                                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                                         </textFieldCell>
                                         <connections>
-                                            <binding destination="0Or-bh-QJU" name="value" keyPath="selection.type" id="qUO-gT-OT1">
+                                            <binding destination="0Or-bh-QJU" name="value" keyPath="selection.typeName" id="gwS-Dq-GX6">
                                                 <dictionary key="options">
                                                     <string key="NSNoSelectionPlaceholder" base64-UTF8="YES">
 IA
@@ -229,7 +229,7 @@ IA
                                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                                         </textFieldCell>
                                         <connections>
-                                            <binding destination="0Or-bh-QJU" name="value" keyPath="selection.position" id="l9O-cX-idn">
+                                            <binding destination="0Or-bh-QJU" name="value" keyPath="selection.location" id="vqO-9x-c2s">
                                                 <dictionary key="options">
                                                     <string key="NSNoSelectionPlaceholder" base64-UTF8="YES">
 IA
@@ -295,7 +295,7 @@ IA
                                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                                         </textFieldCell>
                                         <connections>
-                                            <binding destination="0Or-bh-QJU" name="value" keyPath="selection.func" id="7hC-0w-bVD">
+                                            <binding destination="0Or-bh-QJU" name="value" keyPath="selection.function" id="ENe-8J-RIM">
                                                 <dictionary key="options">
                                                     <string key="NSNoSelectionPlaceholder" base64-UTF8="YES">
 IA
@@ -443,13 +443,7 @@ IA
             </toolbar>
             <point key="canvasLocation" x="139" y="192"/>
         </window>
-        <arrayController editable="NO" selectsInsertedObjects="NO" id="0Or-bh-QJU">
-            <declaredKeys>
-                <string>component</string>
-                <string>message</string>
-                <string>type</string>
-                <string>image</string>
-            </declaredKeys>
+        <arrayController objectClassName="VLCLogMessage" editable="NO" selectsInsertedObjects="NO" id="0Or-bh-QJU">
             <connections>
                 <binding destination="-2" name="contentArray" keyPath="self.messagesArray" id="nWK-kZ-4HF"/>
             </connections>
diff --git a/modules/gui/macosx/VLCLogMessage.h b/modules/gui/macosx/VLCLogMessage.h
new file mode 100644
index 0000000000..566da1ba60
--- /dev/null
+++ b/modules/gui/macosx/VLCLogMessage.h
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * VLCLogMessage.h: Log message class
+ *****************************************************************************
+ * Copyright (C) 2017 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 at gmail dot com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Foundation/Foundation.h>
+#import <vlc_common.h>
+
+ at interface VLCLogMessage : NSObject
+
+ at property (readonly, getter=typeName) NSString *typeName;
+ at property (readonly) int type;
+ at property (readonly) NSString *message;
+ at property (readonly) NSString *component;
+ at property (readonly) NSString *function;
+ at property (readonly) NSString *location;
+ at property (readonly, getter=fullMessage) NSString *fullMessage;
+
++ (instancetype)logMessage:(char *)msg type:(int)type info:(const vlc_log_t *)info;
+- (instancetype)initWithMessage:(char *)message type:(int)type info:(const vlc_log_t *)info;
+
+ at end
diff --git a/modules/gui/macosx/VLCLogMessage.m b/modules/gui/macosx/VLCLogMessage.m
new file mode 100644
index 0000000000..60c575353e
--- /dev/null
+++ b/modules/gui/macosx/VLCLogMessage.m
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * VLCLogMessage.m: Log message class
+ *****************************************************************************
+ * Copyright (C) 2017 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 at gmail dot com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCLogMessage.h"
+
+ at implementation VLCLogMessage
+
++ (instancetype)logMessage:(char *)msg type:(int)type info:(const vlc_log_t *)info
+{
+    return [[VLCLogMessage alloc] initWithMessage:msg type:type info:info];
+}
+
+- (instancetype)initWithMessage:(char *)message type:(int)type info:(const vlc_log_t *)info
+{
+    self = [super init];
+    if (self) {
+        if (!message || !info->psz_module)
+            return nil;
+        
+        _type = type;
+        _message = [NSString stringWithUTF8String:message];
+        _location = [NSString stringWithFormat:@"%s:%i", info->file, info->line];
+        _component = [NSString stringWithUTF8String:info->psz_module];
+        _function = [NSString stringWithUTF8String:info->func];
+    }
+    return self;
+}
+
+- (NSString *)fullMessage
+{
+    return [NSString stringWithFormat:@"%@ %@: %@", _component, self.typeName, _message];
+}
+
+- (NSString *)typeName
+{
+    switch (_type) {
+        case VLC_MSG_INFO:
+            return @"info";
+        case VLC_MSG_ERR:
+            return @"error";
+        case VLC_MSG_WARN:
+            return @"warning";
+        case VLC_MSG_DBG:
+            return @"debug";
+        default:
+            return @"unknown";
+    }
+}
+
+ at end
diff --git a/modules/gui/macosx/VLCLogWindowController.m b/modules/gui/macosx/VLCLogWindowController.m
index 34590d1e43..2e976276e1 100644
--- a/modules/gui/macosx/VLCLogWindowController.m
+++ b/modules/gui/macosx/VLCLogWindowController.m
@@ -24,6 +24,7 @@
  *****************************************************************************/
 
 #import "VLCLogWindowController.h"
+#import "VLCLogMessage.h"
 #import "VLCMain.h"
 #import <vlc_common.h>
 
@@ -42,7 +43,7 @@
  */
 @property (retain) NSTimer        *refreshTimer;
 
-- (void)addMessage:(NSDictionary *)message;
+- (void)addMessage:(VLCLogMessage *)message;
 
 @end
 
@@ -56,27 +57,14 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
     @autoreleasepool {
         char *msg;
         VLCLogWindowController *controller = (__bridge VLCLogWindowController*)data;
-        static NSString *types[4] = { @"info", @"error", @"warning", @"debug" };
 
         if (vasprintf(&msg, format, ap) == -1) {
             return;
         }
-
-        if (!item->psz_module || !msg) {
-            free(msg);
-            return;
-        }
-
-        NSString *position = [NSString stringWithFormat:@"%s:%i", item->file, item->line];
-
-        NSDictionary *messageDict = @{
-                                      @"type"       : types[type],
-                                      @"message"    : toNSStr(msg),
-                                      @"component"  : toNSStr(item->psz_module),
-                                      @"position"   : position,
-                                      @"func"       : toNSStr(item->func)
-                                      };
-        [controller addMessage:messageDict];
+        
+        [controller addMessage:[VLCLogMessage logMessage:msg
+                                                    type:type
+                                                    info:item]];
         free(msg);
     }
 }
@@ -175,16 +163,16 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
     static dispatch_once_t onceToken;
     dispatch_once(&onceToken, ^{
         colors = @{
-                   @"info"     : [NSColor colorWithCalibratedRed:0.65 green:0.91 blue:1.0 alpha:0.7],
-                   @"error"    : [NSColor colorWithCalibratedRed:1.0 green:0.49 blue:0.45 alpha:0.5],
-                   @"warning"  : [NSColor colorWithCalibratedRed:1.0 green:0.88 blue:0.45 alpha:0.7],
-                   @"debug"    : [NSColor colorWithCalibratedRed:0.96 green:0.96 blue:0.96 alpha:0.5]
+                   @(VLC_MSG_INFO): [NSColor colorWithCalibratedRed:0.65 green:0.91 blue:1.0 alpha:0.7],
+                   @(VLC_MSG_ERR) : [NSColor colorWithCalibratedRed:1.0 green:0.49 blue:0.45 alpha:0.5],
+                   @(VLC_MSG_WARN): [NSColor colorWithCalibratedRed:1.0 green:0.88 blue:0.45 alpha:0.7],
+                   @(VLC_MSG_DBG) : [NSColor colorWithCalibratedRed:0.96 green:0.96 blue:0.96 alpha:0.5]
                    };
     });
 
     // Lookup color for message type
-    NSDictionary *message = [[_arrayController arrangedObjects] objectAtIndex:row];
-    rowView.backgroundColor = [colors objectForKey:[message objectForKey:@"type"]];
+    VLCLogMessage *message = [[_arrayController arrangedObjects] objectAtIndex:row];
+    rowView.backgroundColor = [colors objectForKey:@(message.type)];
 }
 
 - (void)splitViewDidResizeSubviews:(NSNotification *)notification
@@ -215,15 +203,11 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
         }
         NSMutableString *string = [[NSMutableString alloc] init];
 
-        for (NSDictionary *line in _messagesArray) {
-            NSString *message = [NSString stringWithFormat:@"%@ %@ %@\n",
-                                 [line objectForKey:@"component"],
-                                 [line objectForKey:@"type"],
-                                 [line objectForKey:@"message"]];
-            [string appendString:message];
+        for (VLCLogMessage *message in _messagesArray) {
+            [string appendFormat:@"%@\r\n", message.fullMessage];
         }
         NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
-        if ([data writeToFile: [[saveFolderPanel URL] path] atomically: YES] == NO)
+        if ([data writeToFile:[[saveFolderPanel URL] path] atomically:YES] == NO)
             msg_Warn(getIntf(), "Error while saving the debug log");
     }];
 }
@@ -267,12 +251,8 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
 - (void) copy:(id)sender {
     NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
     [pasteBoard clearContents];
-    for (NSDictionary *line in [_arrayController selectedObjects]) {
-        NSString *message = [NSString stringWithFormat:@"%@ %@: %@",
-                             [line objectForKey:@"component"],
-                             [line objectForKey:@"type"],
-                             [line objectForKey:@"message"]];
-        [pasteBoard writeObjects:@[message]];
+    for (VLCLogMessage *message in [_arrayController selectedObjects]) {
+        [pasteBoard writeObjects:@[message.fullMessage]];
     }
 }
 
@@ -304,10 +284,13 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
  Adds a message to the messageBuffer, it does not has to be called from the main thread, as
  items are only added to the messageArray on refresh.
  */
-- (void)addMessage:(NSDictionary *)messageDict
+- (void)addMessage:(VLCLogMessage *)message
 {
+    if (!message)
+        return;
+
     @synchronized (_messageBuffer) {
-        [_messageBuffer addObject:messageDict];
+        [_messageBuffer addObject:message];
     }
 }
 



More information about the vlc-commits mailing list