Patchwork [2/6] Cocoa: avoid displaying window when command-line contains '-h'

login
register
mail settings
Submitter Alexandre Raymond
Date May 27, 2011, 5:22 p.m.
Message ID <1306516951-31105-3-git-send-email-cerbere@gmail.com>
Download mbox | patch
Permalink /patch/97723/
State New
Headers show

Comments

Alexandre Raymond - May 27, 2011, 5:22 p.m.
There was already a check in place to avoid displaying a window
in certain modes such as vnc, nographic or curses.

Add a check for '-h' to avoid displaying a window for a split-
second before showing the usage information.

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
---
 ui/cocoa.m |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Andreas Färber - May 28, 2011, 3:05 p.m.
Am 27.05.2011 um 19:22 schrieb Alexandre Raymond:

> There was already a check in place to avoid displaying a window
> in certain modes such as vnc, nographic or curses.
>
> Add a check for '-h' to avoid displaying a window for a split-
> second before showing the usage information.
>
> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
> ---
> ui/cocoa.m |    3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 20f91bc..7fb8d96 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -865,7 +865,8 @@ int main (int argc, const char * argv[]) {
>
>     /* In case we don't need to display a window, let's not do that */
>     for (i = 1; i < argc; i++) {
> -        if (!strcmp(argv[i], "-vnc") ||
> +        if (!strcmp(argv[i], "-h") ||
> +            !strcmp(argv[i], "-vnc") ||
>             !strcmp(argv[i], "-nographic") ||
>             !strcmp(argv[i], "-curses")) {
>                 return qemu_main(gArgc, gArgv);

Nack. I have a patch from Tristan queued (sorry, forgot to send pull  
request before my vacation), please rebase against that.

Cf. http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/cocoa-for-upstream

Also, your patch fails to detect -help.

BTW -M ? and others face a similar detection issue, so I believe while  
adding to this list is a handy short-term fix, we need a better  
solution there. Suggestions and patches welcome.

Andreas

Patch

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 20f91bc..7fb8d96 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -865,7 +865,8 @@  int main (int argc, const char * argv[]) {
 
     /* In case we don't need to display a window, let's not do that */
     for (i = 1; i < argc; i++) {
-        if (!strcmp(argv[i], "-vnc") ||
+        if (!strcmp(argv[i], "-h") ||
+            !strcmp(argv[i], "-vnc") ||
             !strcmp(argv[i], "-nographic") ||
             !strcmp(argv[i], "-curses")) {
                 return qemu_main(gArgc, gArgv);