Patchwork Cocoa: avoid warning related to multiple method definitions

login
register
mail settings
Submitter Alexandre Raymond
Date May 29, 2011, 10:36 p.m.
Message ID <1306708579-16268-1-git-send-email-cerbere@gmail.com>
Download mbox | patch
Permalink /patch/97860/
State New
Headers show

Comments

Alexandre Raymond - May 29, 2011, 10:36 p.m.
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<---

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
---
 ui/cocoa.m |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Andreas Färber - May 31, 2011, 8:07 p.m.
Hello Alexandre,

Am 30.05.2011 um 00:36 schrieb Alexandre Raymond:

> 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.

> ----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

>
> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
> ---
> ui/cocoa.m |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index e1312d3..1975011 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -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();
> -- 
> 1.7.5
>
Alexandre Raymond - June 6, 2011, 11:39 p.m.
Hi Andreas,

On Tue, May 31, 2011 at 4:07 PM, Andreas Färber <andreas.faerber@web.de> wrote:
> Hello Alexandre,
>
> Am 30.05.2011 um 00:36 schrieb Alexandre Raymond:
>
>> 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
Andreas Färber - June 9, 2011, 7:06 p.m.
Hi Alexandre,

Am 07.06.2011 um 01:39 schrieb Alexandre Raymond:

> On Tue, May 31, 2011 at 4:07 PM, Andreas Färber <andreas.faerber@web.de 
> > wrote:
>> Hello Alexandre,
>>
>> Am 30.05.2011 um 00:36 schrieb Alexandre Raymond:
>>
>>> 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 ?

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

Thanks,
Andreas

Patch

diff --git a/ui/cocoa.m b/ui/cocoa.m
index e1312d3..1975011 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -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();