qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] Mac OS X: QEMU crashes when pressing dead keys


From: Joachim Henke
Subject: [Qemu-devel] [PATCH] Mac OS X: QEMU crashes when pressing dead keys
Date: Thu, 8 Dec 2005 18:21:51 +0100

This concerns the current cocoa version in cvs:  When typing into the
monitor and accidentally pressing a dead key, qemu quits immediately and
all unsafed data in the guest os is lost:

2005-12-04 15:15:00.833 qemu[193] Exception raised during posting of 
notification.  Ignored.  exception: *** -[NSCFString characterAtIndex:]: Range 
or index out of bounds

Even if you don't have a Mac, you can retrace this bug by following these
links:

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSEvent.html#//apple_ref/occ/instm/NSEvent/characters
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html#//apple_ref/occ/instm/NSString/characterAtIndex:

[event characters] returns an empty string for dead keys, and so calling
[[event characters] characterAtIndex:0] will raise an NSRangeException that
crashes qemu. The following patch fixes this bug:


Index: cocoa.m
===================================================================
RCS file: /cvsroot/qemu/qemu/cocoa.m,v
retrieving revision 1.5
diff -u -r1.5 cocoa.m
--- cocoa.m     30 Oct 2005 18:24:49 -0000      1.5
+++ cocoa.m     4 Dec 2005 16:16:28 -0000
@@ -454,8 +454,11 @@
                                         kbd_put_keysym(QEMU_KEY_UP);
                                         break;
                                     default:
+                                    {
+                                        NSString *ks = [event characters];
+                                        if ([ks length] > 0)
+                                            kbd_put_keysym([ks 
characterAtIndex:0]);
+                                    }
-                                        kbd_put_keysym([[event characters] 
characterAtIndex:0]);
-                                        break;
                                 }
                             }
                         }


To Mike Kronenberg: Q has the same problem. Pressing a dead key in the
monitor locks the emulation and you're not able to do anything further.
Would you be so kind to confirm this? It seems that Fabrice doesn't trust
my fixes. Thanks!

Regards
        Jo.





reply via email to

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