Bug 9417 - Inappropriate +initialize method added to NSPasteboard via category
Summary: Inappropriate +initialize method added to NSPasteboard via category
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Darin Adler
URL:
Keywords: EasyFix, InRadar
Depends on:
Blocks:
 
Reported: 2006-06-12 09:34 PDT by Jim Correia
Modified: 2007-08-29 23:57 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Correia 2006-06-12 09:34:22 PDT
As of r14819 (*) of the WebKit source, there is code in WebNSPasteBoardExtras.m which looks like this:

(*) The version of WebKit shipping on 10.4.6 does something similar.

@implementation NSPasteboard (WebExtras)

+ (void)initialize
{
	[...]
}

Unlike +load (which is sent to every category), +initialize is only sent once per class, thus the category implementation is going to override the NSPasteboard implementation.

NSPasteboard today doesn't have an +initialize, but if it were to every get one, applications which linked against WebKit would have subtly wrong/different behavior. Some alternative means of initializing the category globals seems like a good idea.

See also rdar://problem/4582212
Comment 1 David Kilzer (:ddkilzer) 2006-06-12 10:02:32 PDT
(In reply to comment #0)
> As of r14819 (*) of the WebKit source, there is code in WebNSPasteBoardExtras.m
> which looks like this:

Looking at 'svn annotate' on WebKit/Misc/WebNSPasteBoardExtras.m, this was added (or at least changed) back in r2185 (when WebKit was still in CVS at Apple) by a user named 'cblu'.  This code is quite old.
Comment 2 Jim Correia 2006-06-12 10:08:40 PDT
I didn't mean for the "as of r14819" to imply that it was new code. Sorry if it has that affect. I just wanted to refer to a revision so if the code changed, the bug make still make sense in the context that I reported it.
Comment 3 David Kilzer (:ddkilzer) 2006-06-12 10:59:49 PDT
(In reply to comment #2)
> I didn't mean for the "as of r14819" to imply that it was new code. Sorry if it
> has that affect. I just wanted to refer to a revision so if the code changed,
> the bug make still make sense in the context that I reported it.

I didn't mean this in a bad way...just doing some additional research for the bug.  :)
Comment 4 Darin Adler 2006-06-12 11:05:55 PDT
We should move this initialization code into a helper function and call that function from any places that use WebURLPboardType or WebURLNamePboardType. Unfortunately, those two are exported in the header file, so we'll have to look all over WebKit to find those places.
Comment 5 Jim Correia 2007-08-29 14:09:43 PDT
This issue is more urgent than when I originally reported it. Additional details appended to <rdar://problem/4582212> since they are subject to NDA.
Comment 6 Darin Adler 2007-08-29 14:28:12 PDT
Thanks! I'll take a look at this.
Comment 7 mitz 2007-08-29 23:57:04 PDT
Fixed by Darin in <http://trac.webkit.org/projects/webkit/changeset/25312>.