Skip to contentSkip to conversation

ui/cocoa.m: fix help menus

PATCH Superseded Programmingkid 2 participants 2 messages Sep 27, 2015 – Oct 13, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/cocoa.m: fix help menus

Make the help menus actually work.

---
 ui/cocoa.m |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
ui/cocoa.m +16 -4
index 334e6f6..2c81785 100644
@@ -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!");
+    }
 }
 
 - (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 */
Signature · 1 line
1.7.5.4
#1 lore raw
Quoted 16 lines · Programmingkid

Make the help menus actually work.

---
 ui/cocoa.m |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
ui/cocoa.m +0 -0
index 334e6f6..2c81785 100644
@@ -992,16 +992,28 @@ QemuCocoaView *cocoaView;
 {
     COCOA_DEBUG("QemuCocoaAppController: showQEMUDoc\n");
 

ui/cocoa.m QemuCocoaView *cocoaView; · line 1002

Quoted 10 lines
ui/cocoa.m +8 -2
-    [[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.

Quoted 9 lines
ui/cocoa.m +1 -2
 }
 
 - (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;

ui/cocoa.m QemuCocoaView *cocoaView; · line 1019

Quoted 10 lines
ui/cocoa.m +7 -0
+    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