All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akihiko Odaki <akihiko.odaki@gmail.com>
To: BALATON Zoltan <balaton@eik.bme.hu>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu Developers <qemu-devel@nongnu.org>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH 2/2] ui/cocoa: Do not rely on the first argument
Date: Wed, 10 Mar 2021 12:31:44 +0900	[thread overview]
Message-ID: <CAMVc7JWO0o9NUwPaE6wBMG+u7zHocWDPxr-6o3OcS5Zm0oT+HA@mail.gmail.com> (raw)
In-Reply-To: <30b88283-8d6b-502b-9032-33c81e26d97@eik.bme.hu>

2021年3月9日(火) 22:10 BALATON Zoltan <balaton@eik.bme.hu>:
>
> On Tue, 9 Mar 2021, Akihiko Odaki wrote:
> > 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>
> > ---
> > ui/cocoa.m | 29 +++++++++++++++--------------
> > 1 file changed, 15 insertions(+), 14 deletions(-)
> >
> > diff --git a/ui/cocoa.m b/ui/cocoa.m
> > index d8eacea6d22..6e94301c0d6 100644
> > --- a/ui/cocoa.m
> > +++ b/ui/cocoa.m
> > @@ -1414,20 +1414,21 @@ - (void)make_about_window
> >     [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) {
>
> Does this break about window if the executable is not in a bundle (like
> when run from the command line after compiling)? Shouldn't you only put
> the qemu_name in this if and have some default name if bundle is not
> available (or fall back to argv[0] in that case?
>
> Regards,
> BALATON Zoltan
>

No, it just doesn't show the application name. Everything else is fine.

Regards,
Akihiko Odaki


  reply	other threads:[~2021-03-10  3:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 12:22 [PATCH 1/2] ui/cocoa: Show QEMU icon in the about window Akihiko Odaki
2021-03-09 12:22 ` [PATCH 2/2] ui/cocoa: Do not rely on the first argument Akihiko Odaki
2021-03-09 13:10   ` BALATON Zoltan
2021-03-10  3:31     ` Akihiko Odaki [this message]
2021-03-10 12:22       ` Gerd Hoffmann
2021-03-10 15:49         ` Akihiko Odaki
2021-03-11  8:31           ` Gerd Hoffmann
2021-03-10 12:23 ` [PATCH 1/2] ui/cocoa: Show QEMU icon in the about window Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMVc7JWO0o9NUwPaE6wBMG+u7zHocWDPxr-6o3OcS5Zm0oT+HA@mail.gmail.com \
    --to=akihiko.odaki@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.