qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] ui/cocoa.m: fix help menus


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] ui/cocoa.m: fix help menus
Date: Tue, 13 Oct 2015 21:40:14 +0100

On 27 September 2015 at 15:31, Programmingkid <address@hidden> wrote:
> Make the help menus actually work.
>
> Signed-off-by: John Arbuckle <address@hidden>
>
> ---
>  ui/cocoa.m |   20 ++++++++++++++++----
>  1 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 334e6f6..2c81785 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -992,16 +992,28 @@ QemuCocoaView *cocoaView;
>  {
>      COCOA_DEBUG("QemuCocoaAppController: showQEMUDoc\n");
>
> -    [[NSWorkspace sharedWorkspace] openFile:[NSString 
> stringWithFormat:@"%@/../doc/qemu/qemu-doc.html",
> -        [[NSBundle mainBundle] resourcePath]] withApplication:@"Help 
> Viewer"];
> +    NSString *path;
> +    path = [[NSBundle mainBundle] resourcePath];
> +    path = [path stringByDeletingLastPathComponent];
> +    path = [NSString stringWithFormat: @"%@/%s", path, "qemu-doc.html"];
> +    if([[NSWorkspace sharedWorkspace] openFile: path] == NO) {
> +        NSBeep();
> +        QEMU_Alert(@"Failed to open file qemu-doc.html!");
> +    }

This looks like it changes the place we look for the docs
from "../doc/qemu/" to "../".  The latter will work if you're
running QEMU directly from a build tree, but if you've installed
QEMU via 'make install' then we put docs into
 ${prefix}/share/doc/qemu
and binaries into
 ${prefix}/bin
so we need also to search "../share/doc/qemu/". (I think the
current code is attempting to do the latter but is buggy.
This also doesn't account for users manually passing --docdir
to configure, but I think that's pretty hard to do.)

If you want to add support for finding the docs when running
directly from a build tree then we need to check that search
path as well as the one for an installed setup.

>  }
>
>  - (void)showQEMUTec:(id)sender
>  {
>      COCOA_DEBUG("QemuCocoaAppController: showQEMUTec\n");
>
> -    [[NSWorkspace sharedWorkspace] openFile:[NSString 
> stringWithFormat:@"%@/../doc/qemu/qemu-tech.html",
> -        [[NSBundle mainBundle] resourcePath]] withApplication:@"Help 
> Viewer"];
> +    NSString *path;
> +    path = [[NSBundle mainBundle] resourcePath];
> +    path = [path stringByDeletingLastPathComponent];
> +    path = [NSString stringWithFormat: @"%@/%s", path, "qemu-tech.html"];
> +    if([[NSWorkspace sharedWorkspace] openFile: path] == NO) {
> +        NSBeep();
> +        QEMU_Alert(@"Failed to open file qemu-tech.html!");
> +    }
>  }
>
>  /* Stretches video to fit host monitor size */

You now have two lots of identical code which differ only by
what file they're looking for; this would be better refactored
out into a separate function (especially if you want to search
more than one path).

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]