Skip to contentSkip to conversation

Cocoa: avoid warning related to multiple method definitions

PATCH In review Alexandre Raymond 2 participants 7 messages May 29, 2011 – Jun 12, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Cocoa: avoid warning related to multiple method definitions

This fix forces a message to be sent to the handleEvent method of the QemuCocoaView class instead of letting the system determine the right method.

This is caused by the fact that the cocoaView variable is a generic 'id'.

----8<----
ui/cocoa.m: In function ‘cocoa_refresh’:
ui/cocoa.m:997: warning: multiple methods named ‘-handleEvent:’ found /System/Library/Frameworks/AppKit.framework/Headers/NSTextInputContext.h:84: warning: using ‘-(BOOL)handleEvent:(NSEvent *)theEvent’ ui/cocoa.m:272: warning: also found ‘-(void)handleEvent:(NSEvent *)event’
----8<---

---
 ui/cocoa.m |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ui/cocoa.m +1 -1
index e1312d3..1975011 100644
@@ -994,7 +994,7 @@ static void cocoa_refresh(DisplayState *ds)
         event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:distantPast
                         inMode: NSDefaultRunLoopMode dequeue:YES];
         if (event != nil) {
-            [cocoaView handleEvent:event];
+            [(QemuCocoaView *) cocoaView handleEvent:event];
         }
     } while(event != nil);
     vga_hw_update();
Signature · 1 line
1.7.5
#1 lore raw

Hello Alexandre,

Am 30.05.2011 um 00:36 schrieb Alexandre Raymond:

Quoted 5 lines

This fix forces a message to be sent to the handleEvent method of the QemuCocoaView class instead of letting the system determine the right method.

This is caused by the fact that the cocoaView variable is a generic 'id'.

In that case I would prefer to change the variable definition, moving it further down, instead of introducing a cast.

Quoted 6 lines

----8<----
ui/cocoa.m: In function ‘cocoa_refresh’:
ui/cocoa.m:997: warning: multiple methods named ‘-handleEvent:’ found /System/Library/Frameworks/AppKit.framework/Headers/NSTextInputContext.h:84: warning: using ‘-(BOOL)handleEvent:(NSEvent *)theEvent’ ui/cocoa.m:272: warning: also found ‘-(void)handleEvent:(NSEvent *)event’
----8<---

Since I'm not seeing this issue on v10.5, it seems a new method was introduced by Apple in v10.6.

Not in NSView (QemuCocoaView's parent class):
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html

but in unrelated NSTextInputContext class:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSTextInputContext_Class/Reference/Reference.html

So, it seems the warning stems from the name clash of two identical selectors "handleEvent:" with differing return type (void vs. BOOL). I vaguely remember seeing a patch that renames our method, either in Juha's 48-patch series Peter pointed to or in a patch by C.W. Betts.

If you haven't already, could you please check on that? Maybe it's safest to do both? Or to change our return type even if unused?

Andreas

Quoted 23 lines

---
ui/cocoa.m | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
ui/cocoa.m +0 -0
index e1312d3..1975011 100644
@@ -994,7 +994,7 @@ static void cocoa_refresh(DisplayState *ds)
        event = [NSApp nextEventMatchingMask:NSAnyEventMask  

untilDate:distantPast

                        inMode: NSDefaultRunLoopMode dequeue:YES];
        if (event != nil) {
ui/cocoa.m +1 -1
-            [cocoaView handleEvent:event];
+            [(QemuCocoaView *) cocoaView handleEvent:event];
        }
    } while(event != nil);
    vga_hw_update();
Signature · 1 line
1.7.5
#2 lore raw

Hi Andreas,

Quoted 4 lines · Andreas Färber

Hello Alexandre,

Am 30.05.2011 um 00:36 schrieb Alexandre Raymond:

Quoted 8 lines
Quoted 5 lines

This fix forces a message to be sent to the handleEvent method of the QemuCocoaView class instead of letting the system determine the right method.

This is caused by the fact that the cocoaView variable is a generic 'id'.

In that case I would prefer to change the variable definition, moving it further down, instead of introducing a cast.

I am working on a cleanup of the cocoa code. As a temporary fix, would you accept a simple patch renaming handleEvent to handleGUIEvent in order to avoid the compilation warning ?

Alexandre

#3 lore raw

PATCH 1/1 cocoa: Avoid warning related to multiple handleEvent: definitions

Avoid compiler confusion as to which method signature to use for the
handleEvent: selector on OSX >= 10.6 by making the variable type-safe as opposed to generic 'id' type.
Requires moving the variable definition to after the class definition.

----8<----
ui/cocoa.m: In function ‘cocoa_refresh’:
ui/cocoa.m:997: warning: multiple methods named ‘-handleEvent:’ found /System/Library/Frameworks/AppKit.framework/Headers/NSTextInputContext.h:84: warning: using ‘-(BOOL)handleEvent:(NSEvent *)theEvent’ ui/cocoa.m:272: warning: also found ‘-(void)handleEvent:(NSEvent *)event’
----8<---

---
 ui/cocoa.m |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
ui/cocoa.m +2 -1
index 1c54759..515e684 100644
@@ -63,7 +63,6 @@ typedef struct {
 } QEMUScreen;
 
 NSWindow *normalWindow;
-id cocoaView;
 static DisplayChangeListener *dcl;
 
 int gArgc;
@@ -278,6 +277,8 @@ static int cocoa_keycode_to_qemu(int keycode)
 - (QEMUScreen) gscreen;
 @end
 
+QemuCocoaView *cocoaView;
+
 @implementation QemuCocoaView
 - (id)initWithFrame:(NSRect)frameRect
 {
Signature · 1 line
1.7.5.3
author Tested-by on v1 1/1
#4 lore raw

Re: [Qemu-devel] [PATCH] cocoa: Avoid warning related to multiple handleEvent: definitions

That's definitely a better patch ;-)

Thanks,
Alexandre

Quoted 44 lines · Andreas Färber

Avoid compiler confusion as to which method signature to use for the
handleEvent: selector on OSX >= 10.6 by making the variable type-safe as opposed to generic 'id' type.
Requires moving the variable definition to after the class definition.

----8<----
ui/cocoa.m: In function ‘cocoa_refresh’:
ui/cocoa.m:997: warning: multiple methods named ‘-handleEvent:’ found /System/Library/Frameworks/AppKit.framework/Headers/NSTextInputContext.h:84: warning: using ‘-(BOOL)handleEvent:(NSEvent *)theEvent’ ui/cocoa.m:272: warning: also found ‘-(void)handleEvent:(NSEvent *)event’
----8<---

---
 ui/cocoa.m |    3 ++-

 1 files changed, 2 insertions(+), 1 deletions(-)
ui/cocoa.m +0 -1
index 1c54759..515e684 100644
@@ -63,7 +63,6 @@ typedef struct {
  } QEMUScreen;
 
  NSWindow *normalWindow;
-id cocoaView;
  static DisplayChangeListener *dcl;
 
  int gArgc;
@@ -278,6 +277,8 @@ static int cocoa_keycode_to_qemu(int keycode)
  - (QEMUScreen) gscreen;

 @end

ui/cocoa.m +2 -0
+QemuCocoaView *cocoaView;
+

 @implementation QemuCocoaView
 - (id)initWithFrame:(NSRect)frameRect
 {
--
1.7.5.3

#5 lore raw

Re: [Qemu-devel] [PATCH] cocoa: Avoid warning related to multiple handleEvent: definitions

Am 10.06.2011 um 04:47 schrieb Alexandre Raymond:

Quoted 3 lines

That's definitely a better patch ;-)

Thanks, applied to the cocoa branch.

Andreas

Quoted 51 lines

Thanks,
Alexandre

Quoted 44 lines · Andreas Färber

Avoid compiler confusion as to which method signature to use for the
handleEvent: selector on OSX >= 10.6 by making the variable type-safe as opposed to generic 'id' type.
Requires moving the variable definition to after the class definition.

----8<----
ui/cocoa.m: In function ‘cocoa_refresh’:
ui/cocoa.m:997: warning: multiple methods named ‘-handleEvent:’ found /System/Library/Frameworks/AppKit.framework/Headers/NSTextInputContext.h:84: warning: using ‘-(BOOL)handleEvent:(NSEvent *)theEvent’ ui/cocoa.m:272: warning: also found ‘-(void)handleEvent:(NSEvent *)event’
----8<---

---
 ui/cocoa.m |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
ui/cocoa.m +2 -2
index 1c54759..515e684 100644
@@ -63,7 +63,6 @@ typedef struct {
 } QEMUScreen;
 
 NSWindow *normalWindow;
-id cocoaView;
 static DisplayChangeListener *dcl;
 
 int gArgc;
@@ -278,6 +277,8 @@ static int cocoa_keycode_to_qemu(int keycode)
 - (QEMUScreen) gscreen;
 @end
 
+QemuCocoaView *cocoaView;
+
 @implementation QemuCocoaView
 - (id)initWithFrame:(NSRect)frameRect
 {
--

1.7.5.3

#6 lore raw
In reply to Alexandre Raymond

Hi Alexandre,

Am 07.06.2011 um 01:39 schrieb Alexandre Raymond:

Quoted 10 lines

On Tue, May 31, 2011 at 4:07 PM, Andreas Färber <[email protected]

Quoted 9 lines

wrote:
Hello Alexandre,

Am 30.05.2011 um 00:36 schrieb Alexandre Raymond:

Quoted 4 lines

This fix forces a message to be sent to the handleEvent method of the QemuCocoaView class instead of letting the system determine the right method.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

This is caused by the fact that the cocoaView variable is a generic 'id'.

In that case I would prefer to change the variable definition, moving it further down, instead of introducing a cast.

I am working on a cleanup of the cocoa code. As a temporary fix, would you accept a simple patch renaming handleEvent to handleGUIEvent in order to avoid the compilation warning ?

Could you please test the new patch for the above solution that I just submitted?

Thanks,
Andreas