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>
This commit is contained in:
Akihiko Odaki 2021-03-09 21:22:26 +09:00 committed by Gerd Hoffmann
parent e31746ecf8
commit a0f973f931

View File

@ -1398,6 +1398,8 @@ - (void)make_about_window
[superView addSubview: picture_view]; [superView addSubview: picture_view];
/* Make the name label */ /* Make the name label */
NSBundle *bundle = [NSBundle mainBundle];
if (bundle) {
x = 0; x = 0;
y = y - 25; y = y - 25;
int name_width = about_width, name_height = 20; int name_width = about_width, name_height = 20;
@ -1407,11 +1409,10 @@ - (void)make_about_window
[name_label setBezeled: NO]; [name_label setBezeled: NO];
[name_label setDrawsBackground: NO]; [name_label setDrawsBackground: NO];
[name_label setAlignment: NSTextAlignmentCenter]; [name_label setAlignment: NSTextAlignmentCenter];
NSString *qemu_name = [[NSString alloc] initWithCString: gArgv[0] NSString *qemu_name = [[bundle executablePath] lastPathComponent];
encoding: NSASCIIStringEncoding];
qemu_name = [qemu_name lastPathComponent];
[name_label setStringValue: qemu_name]; [name_label setStringValue: qemu_name];
[superView addSubview: name_label]; [superView addSubview: name_label];
}
/* Set the version label's attributes */ /* Set the version label's attributes */
x = 0; x = 0;