Bug 17153 - wxFont objects become invalid and cause a crash
Summary: wxFont objects become invalid and cause a crash
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit wx (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-02 11:21 PST by Kevin Watters
Modified: 2008-02-02 12:39 PST (History)
0 users

See Also:


Attachments
FontPlatformData uses wxFont as a value object (8.73 KB, patch)
2008-02-02 11:26 PST, Kevin Watters
kevino: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Watters 2008-02-02 11:21:57 PST
The wxFont objects used in FontPlatformDataWx.h and FontPlatformDataWx.cpp are reference counted value objects meant to be used on the stack. Using a pointer to store them in FontPlatformData objects is causing sporadic crashes.
Comment 1 Kevin Watters 2008-02-02 11:26:59 PST
Created attachment 18869 [details]
FontPlatformData uses wxFont as a value object

Fixes FontPlatformData issues. 

Reference counting of wxFont objects happens correctly now because they are stored as value objects.  An enum is used to maintain the "uninitialized," "deleted," and "valid" states since all three are used by a HashTable holding FontPlatformData objects.

computeHash now uses a hash of the string returned by wxFont::GetNativeInfoDesc, which uniquely identifies a wxFont and all its attributes.

Additionally, a missing delete in ImageWx.cpp is added.
Comment 2 Kevin Ollivier 2008-02-02 11:50:29 PST
Comment on attachment 18869 [details]
FontPlatformData uses wxFont as a value object

Looks good. This patch does resolve crashes I've been seeing related to fonts on my machine as well.
Comment 3 Kevin Ollivier 2008-02-02 12:39:41 PST
Landed in r29940. THanks!