All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29
@ 2013-05-28 23:51 Andreas Färber
  2013-05-28 23:51 ` [Qemu-devel] [PULL 1/4] cocoa: Fix leaks of NSScreen and NSConcreteMapTable Andreas Färber
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andreas Färber @ 2013-05-28 23:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Andreas Färber

Hello,

This is the current Cocoa queue. Please pull.

It contains warning fixes for Mac OS X v10.8 and drops support for v10.2 and earlier.

Cc: Peter Maydell <peter.maydell@linaro.org>

The following changes since commit 6a4e17711442849bf2cc731ccddef5a2a2d92d29:

  Remove Sun4c, Sun4d and a few CPUs (2013-05-26 11:37:58 +0000)

are available in the git repository at:

  git://repo.or.cz/qemu/afaerber.git cocoa-for-upstream

for you to fetch changes up to 2ba9de6ed0455f5c55e4fb1841e1597204535430:

  cocoa: Avoid deprecated NSOpenPanel beginSheetForDirectory (2013-05-29 01:28:31 +0200)

----------------------------------------------------------------
Peter Maydell (4):
      cocoa: Fix leaks of NSScreen and NSConcreteMapTable
      cocoa: Avoid deprecated CPS* functions
      cocoa: Avoid deprecated NSOpenPanel filename method
      cocoa: Avoid deprecated NSOpenPanel beginSheetForDirectory

 ui/cocoa.m | 52 ++++++++++++++++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 20 deletions(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 1/4] cocoa: Fix leaks of NSScreen and NSConcreteMapTable
  2013-05-28 23:51 [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29 Andreas Färber
@ 2013-05-28 23:51 ` Andreas Färber
  2013-05-28 23:51 ` [Qemu-devel] [PULL 2/4] cocoa: Avoid deprecated CPS* functions Andreas Färber
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Färber @ 2013-05-28 23:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Anthony Liguori

From: Peter Maydell <peter.maydell@linaro.org>

On MacOSX 10.8 QEMU provokes system log messages:
11/03/2013 17:03:29.998 qemu-system-arm[42586]: objc[42586]: Object
0x7ffbf9c2f3b0 of class NSScreen autoreleased with no pool in place - just
leaking - break on objc_autoreleaseNoPool() to debug

11/03/2013 17:03:29.999 qemu-system-arm[42586]: objc[42586]: Object
0x7ffbf9c3a010 of class NSConcreteMapTable autoreleased with no pool in
place - just leaking - break on objc_autoreleaseNoPool() to debug

This is because we call back into Cocoa from threads other than
the UI thread (specifically from the CPU thread). Since we created
these threads via the POSIX API rather than NSThread, they don't have
automatically created autorelease pools. Guard all the functions where
QEMU can call back into the Cocoa UI code with autorelease pools
so that we don't leak any Cocoa objects.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 ui/cocoa.m | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 1971d9c..5d7a1e0 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -960,6 +960,8 @@ int main (int argc, const char * argv[]) {
 static void cocoa_update(DisplayChangeListener *dcl,
                          int x, int y, int w, int h)
 {
+    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
     COCOA_DEBUG("qemu_cocoa: cocoa_update\n");
 
     NSRect rect;
@@ -973,18 +975,24 @@ static void cocoa_update(DisplayChangeListener *dcl,
             h * [cocoaView cdy]);
     }
     [cocoaView setNeedsDisplayInRect:rect];
+
+    [pool release];
 }
 
 static void cocoa_switch(DisplayChangeListener *dcl,
                          DisplaySurface *surface)
 {
-    COCOA_DEBUG("qemu_cocoa: cocoa_resize\n");
+    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
 
+    COCOA_DEBUG("qemu_cocoa: cocoa_switch\n");
     [cocoaView switchSurface:surface];
+    [pool release];
 }
 
 static void cocoa_refresh(DisplayChangeListener *dcl)
 {
+    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
     COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n");
 
     if (kbd_mouse_is_absolute()) {
@@ -1007,6 +1015,7 @@ static void cocoa_refresh(DisplayChangeListener *dcl)
         }
     } while(event != nil);
     graphic_hw_update(NULL);
+    [pool release];
 }
 
 static void cocoa_cleanup(void)
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 2/4] cocoa: Avoid deprecated CPS* functions
  2013-05-28 23:51 [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29 Andreas Färber
  2013-05-28 23:51 ` [Qemu-devel] [PULL 1/4] cocoa: Fix leaks of NSScreen and NSConcreteMapTable Andreas Färber
@ 2013-05-28 23:51 ` Andreas Färber
  2013-05-28 23:51 ` [Qemu-devel] [PULL 3/4] cocoa: Avoid deprecated NSOpenPanel filename method Andreas Färber
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Färber @ 2013-05-28 23:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Anthony Liguori

From: Peter Maydell <peter.maydell@linaro.org>

The functions CPSGetCurrentProcess and CPSEnableForegroundOperation
are deprecated in newer versions of MacOSX and cause warning messages
to be logged to the system log. Instead, use the new preferred method
of promoting our console process up to a graphical app with menubar
and Dock icon, which is TransformProcessType. (This function came
in with MacOSX 10.3, so there's no need to retain the old method as
we don't support anything earlier than 10.3 anyway.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 ui/cocoa.m | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 5d7a1e0..ec09728 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -851,22 +851,10 @@ QemuCocoaView *cocoaView;
 
 
 
-// Dock Connection
-typedef struct CPSProcessSerNum
-{
-        UInt32                lo;
-        UInt32                hi;
-} CPSProcessSerNum;
-
-OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
-OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
-OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
-
 int main (int argc, const char * argv[]) {
 
     gArgc = argc;
     gArgv = (char **)argv;
-    CPSProcessSerNum PSN;
     int i;
 
     /* In case we don't need to display a window, let's not do that */
@@ -890,12 +878,13 @@ int main (int argc, const char * argv[]) {
     }
 
     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-    [NSApplication sharedApplication];
 
-    if (!CPSGetCurrentProcess(&PSN))
-        if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
-            if (!CPSSetFrontProcess(&PSN))
-                [NSApplication sharedApplication];
+    // Pull this console process up to being a fully-fledged graphical
+    // app with a menubar and Dock icon
+    ProcessSerialNumber psn = { 0, kCurrentProcess };
+    TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+
+    [NSApplication sharedApplication];
 
     // Add menus
     NSMenu      *menu;
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 3/4] cocoa: Avoid deprecated NSOpenPanel filename method
  2013-05-28 23:51 [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29 Andreas Färber
  2013-05-28 23:51 ` [Qemu-devel] [PULL 1/4] cocoa: Fix leaks of NSScreen and NSConcreteMapTable Andreas Färber
  2013-05-28 23:51 ` [Qemu-devel] [PULL 2/4] cocoa: Avoid deprecated CPS* functions Andreas Färber
@ 2013-05-28 23:51 ` Andreas Färber
  2013-05-28 23:51 ` [Qemu-devel] [PULL 4/4] cocoa: Avoid deprecated NSOpenPanel beginSheetForDirectory Andreas Färber
  2013-06-17 21:18 ` [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29 Anthony Liguori
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Färber @ 2013-05-28 23:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Anthony Liguori

From: Peter Maydell <peter.maydell@linaro.org>

Avoid the NSOpenPanel filename method (deprecated in MacOSX 10.6)
in favour of using the URL method and extracting the path from the
resulting NSUrl object.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 ui/cocoa.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index ec09728..bb59511 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -810,7 +810,7 @@ QemuCocoaView *cocoaView;
         exit(0);
     } else if(returnCode == NSOKButton) {
         const char *bin = "qemu";
-        char *img = (char*)[ [ sheet filename ] cStringUsingEncoding:NSASCIIStringEncoding];
+        char *img = (char*)[ [ [ sheet URL ] path ] cStringUsingEncoding:NSASCIIStringEncoding];
 
         char **argv = (char**)malloc( sizeof(char*)*3 );
 
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 4/4] cocoa: Avoid deprecated NSOpenPanel beginSheetForDirectory
  2013-05-28 23:51 [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29 Andreas Färber
                   ` (2 preceding siblings ...)
  2013-05-28 23:51 ` [Qemu-devel] [PULL 3/4] cocoa: Avoid deprecated NSOpenPanel filename method Andreas Färber
@ 2013-05-28 23:51 ` Andreas Färber
  2013-06-17 21:18 ` [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29 Anthony Liguori
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Färber @ 2013-05-28 23:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Anthony Liguori

From: Peter Maydell <peter.maydell@linaro.org>

In MacOSX 10.6 and above the NSOpenPanel beginSheetForDirectory
method is deprecated. Use the preferred replacements instead.
We retain the original code for use on earlier MacOSX versions
because the replacement methods don't exist before 10.6.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 ui/cocoa.m | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index bb59511..be49179 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -35,6 +35,9 @@
 #ifndef MAC_OS_X_VERSION_10_5
 #define MAC_OS_X_VERSION_10_5 1050
 #endif
+#ifndef MAC_OS_X_VERSION_10_6
+#define MAC_OS_X_VERSION_10_6 1060
+#endif
 
 
 //#define DEBUG
@@ -771,9 +774,20 @@ QemuCocoaView *cocoaView;
         NSOpenPanel *op = [[NSOpenPanel alloc] init];
         [op setPrompt:@"Boot image"];
         [op setMessage:@"Select the disk image you want to boot.\n\nHit the \"Cancel\" button to quit"];
-        [op beginSheetForDirectory:nil file:nil types:[NSArray arrayWithObjects:@"img",@"iso",@"dmg",@"qcow",@"cow",@"cloop",@"vmdk",nil]
+        NSArray *filetypes = [NSArray arrayWithObjects:@"img", @"iso", @"dmg",
+                                 @"qcow", @"cow", @"cloop", @"vmdk", nil];
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
+        [op setAllowedFileTypes:filetypes];
+        [op beginSheetModalForWindow:normalWindow
+            completionHandler:^(NSInteger returnCode)
+            { [self openPanelDidEnd:op
+                  returnCode:returnCode contextInfo:NULL ]; } ];
+#else
+        // Compatibility code for pre-10.6, using deprecated method
+        [op beginSheetForDirectory:nil file:nil types:filetypes
               modalForWindow:normalWindow modalDelegate:self
               didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL];
+#endif
     } else {
         // or launch QEMU, with the global args
         [self startEmulationWithArgc:gArgc argv:(char **)gArgv];
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29
  2013-05-28 23:51 [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29 Andreas Färber
                   ` (3 preceding siblings ...)
  2013-05-28 23:51 ` [Qemu-devel] [PULL 4/4] cocoa: Avoid deprecated NSOpenPanel beginSheetForDirectory Andreas Färber
@ 2013-06-17 21:18 ` Anthony Liguori
  4 siblings, 0 replies; 6+ messages in thread
From: Anthony Liguori @ 2013-06-17 21:18 UTC (permalink / raw)
  To: None, qemu-devel; +Cc: Peter Maydell

Pulled.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-06-17 21:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-28 23:51 [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29 Andreas Färber
2013-05-28 23:51 ` [Qemu-devel] [PULL 1/4] cocoa: Fix leaks of NSScreen and NSConcreteMapTable Andreas Färber
2013-05-28 23:51 ` [Qemu-devel] [PULL 2/4] cocoa: Avoid deprecated CPS* functions Andreas Färber
2013-05-28 23:51 ` [Qemu-devel] [PULL 3/4] cocoa: Avoid deprecated NSOpenPanel filename method Andreas Färber
2013-05-28 23:51 ` [Qemu-devel] [PULL 4/4] cocoa: Avoid deprecated NSOpenPanel beginSheetForDirectory Andreas Färber
2013-06-17 21:18 ` [Qemu-devel] [PULL 0/4] Cocoa patch queue 2013-05-29 Anthony Liguori

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.