aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki@gmail.com>2021-03-09 21:22:26 +0900
committerGerd Hoffmann <kraxel@redhat.com>2021-03-11 10:06:44 +0100
commita0f973f931680ae8bd847054aca7f658abb9c18f (patch)
tree312cef14d42ccd689ba4f7cb9dea28c56e128974 /ui
parente31746ecf8dd2f25f687c94ac14016a3ba5debfc (diff)
downloadqemu-a0f973f931680ae8bd847054aca7f658abb9c18f.zip
qemu-a0f973f931680ae8bd847054aca7f658abb9c18f.tar.gz
qemu-a0f973f931680ae8bd847054aca7f658abb9c18f.tar.bz2
ui/cocoa: Do not rely on the first argument
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>
Diffstat (limited to 'ui')
-rw-r--r--ui/cocoa.m29
1 files changed, 15 insertions, 14 deletions
diff --git a/ui/cocoa.m b/ui/cocoa.m
index e589534..4753bb2 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;