[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 5/8] ui/cocoa: Do not rely on the first argument
From: |
Gerd Hoffmann |
Subject: |
[PULL 5/8] ui/cocoa: Do not rely on the first argument |
Date: |
Thu, 11 Mar 2021 13:33:58 +0100 |
From: Akihiko Odaki <akihiko.odaki@gmail.com>
The first argument of the executable was used to get its path, but it is
not reliable because the executer can specify any arbitrary string. Use the
interfaces provided by QEMU and the platform to get those paths.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Message-Id: <20210309122226.23117-2-akihiko.odaki@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/cocoa.m | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index e589534fa460..4753bb2f8800 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1398,20 +1398,21 @@ QemuCocoaView *cocoaView;
[superView addSubview: picture_view];
/* Make the name label */
- x = 0;
- y = y - 25;
- int name_width = about_width, name_height = 20;
- NSRect name_rect = NSMakeRect(x, y, name_width, name_height);
- NSTextField *name_label = [[NSTextField alloc] initWithFrame: name_rect];
- [name_label setEditable: NO];
- [name_label setBezeled: NO];
- [name_label setDrawsBackground: NO];
- [name_label setAlignment: NSTextAlignmentCenter];
- NSString *qemu_name = [[NSString alloc] initWithCString: gArgv[0]
- encoding: NSASCIIStringEncoding];
- qemu_name = [qemu_name lastPathComponent];
- [name_label setStringValue: qemu_name];
- [superView addSubview: name_label];
+ NSBundle *bundle = [NSBundle mainBundle];
+ if (bundle) {
+ x = 0;
+ y = y - 25;
+ int name_width = about_width, name_height = 20;
+ NSRect name_rect = NSMakeRect(x, y, name_width, name_height);
+ NSTextField *name_label = [[NSTextField alloc] initWithFrame:
name_rect];
+ [name_label setEditable: NO];
+ [name_label setBezeled: NO];
+ [name_label setDrawsBackground: NO];
+ [name_label setAlignment: NSTextAlignmentCenter];
+ NSString *qemu_name = [[bundle executablePath] lastPathComponent];
+ [name_label setStringValue: qemu_name];
+ [superView addSubview: name_label];
+ }
/* Set the version label's attributes */
x = 0;
--
2.29.2
- [PULL 0/8] Ui 20210311 patches, Gerd Hoffmann, 2021/03/11
- [PULL 2/8] ui/cocoa: Use kCGColorSpaceSRGB, Gerd Hoffmann, 2021/03/11
- [PULL 3/8] docs: Fix removal text of -show-cursor, Gerd Hoffmann, 2021/03/11
- [PULL 4/8] ui/cocoa: Show QEMU icon in the about window, Gerd Hoffmann, 2021/03/11
- [PULL 8/8] ui/cocoa: Fix mouse association state, Gerd Hoffmann, 2021/03/11
- [PULL 7/8] ui/cocoa: Mark variables static, Gerd Hoffmann, 2021/03/11
- [PULL 6/8] ui/cocoa: Clear modifiers whenever possible, Gerd Hoffmann, 2021/03/11
- [PULL 5/8] ui/cocoa: Do not rely on the first argument,
Gerd Hoffmann <=
- [PULL 1/8] ui/gtk: Remove NULL checks in gd_switch, Gerd Hoffmann, 2021/03/11
- Re: [PULL 0/8] Ui 20210311 patches, Peter Maydell, 2021/03/12