On Aug 31, 2008, at 07:36:55, dwt wrote:
> I just stumbled over this notice on <http://growl.info/documentation/
> developer/implementing-growl.php?lang=cocoa>
>
> Bug note: As of 1.1, the Growl Application Bridge requires a delegate
> to be set before you can use it—even if the delegate does not
> implement any delegate methods. As a workaround, use
> [GrowlApplicationBridge setGrowlDelegate:@""] to satisfy it.
>
> Since this bothered me, I fixed it. Here's the patch:
>
> [snip]
>
> It fixes the bug, by calling -setGrowlDelegate: method once, before  
> the class receives it's first message (by using +initialize).

Hm.

One problem with this is that if the application *does* call  
setGrowlDelegate:, then that message (being the first message to the  
class) will trigger +initialize, which will *also* call  
setGrowlDelegate:. This means that most apps will then be sending two  
setGrowlDelegate: messages and each message will attempt to contact  
Growl and wait for a reply. When two replies come in, they will both  
handle the same delegate.

I don't think it's safe to call setGrowlDelegate: more than once in  
rapid succession (with no run loop run between them), which will  
happen in most apps with this patch.

> This of course is not the best fix - the best fix would be to factor  
> that initialization code out of -setGrowlDelegate: ….

Indeed.

Here's a suggestion for an alternate fix:

---
diff --git a/Framework/Source/GrowlApplicationBridge.m b/Framework/ 
Source/GrowlApplicationBridge.m
--- a/Framework/Source/GrowlApplicationBridge.m
+++ b/Framework/Source/GrowlApplicationBridge.m
@@ -246,6 +246,11 @@
  }

  + (void) notifyWithDictionary:(NSDictionary *)userInfo {
+       //Make sure that we have at least attempted to register, even if the  
application has not set a delegate.
+       if (!growlLaunched) {
+               [self setGrowlDelegate:nil];
+       }
+
        //post it.
        if (growlLaunched) {            
                NSProxy<GrowlNotificationProtocol> *currentGrowlProxy = [self  
growlProxy];
---

It's not pretty, but it should work in all cases.

Can anyone think of a case in which it won't?

BTW, I would like for one of us to investigate the difficulty of a  
better fix before we commit to a patch like this one.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Growl Discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/growldiscuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to