aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa
diff options
context:
space:
mode:
authornyamatongwe <nyamatongwe@gmail.com>2012-06-12 21:57:54 +1000
committernyamatongwe <nyamatongwe@gmail.com>2012-06-12 21:57:54 +1000
commit7fd6539ca25bdeaec066f7c25b488b6d96a36a74 (patch)
tree2f48eb82f9c65195b0f2db5a0d8bb376cbf960b6 /cocoa
parent0846de2a587ced6c09ab34b6021bd3969b29e49f (diff)
downloadscintilla-mirror-7fd6539ca25bdeaec066f7c25b488b6d96a36a74.tar.gz
Fix double free of font objects with list box by copying font.
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/PlatCocoa.mm3
-rw-r--r--cocoa/QuartzTextStyle.h12
2 files changed, 14 insertions, 1 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index 5c1213d72..fc7d7c222 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -1604,10 +1604,11 @@ void ListBoxImpl::Create(Window& /*parent*/, int /*ctrlID*/, Scintilla::Point pt
void ListBoxImpl::SetFont(Font& font_)
{
- font.SetID(font_.GetID());
// NSCell setFont takes an NSFont* rather than a CTFontRef but they
// are the same thing toll-free bridged.
QuartzTextStyle* style = reinterpret_cast<QuartzTextStyle*>(font_.GetID());
+ font.Release();
+ font.SetID(new QuartzTextStyle(*style));
NSFont *pfont = (NSFont *)style->getFontRef();
[[colText dataCell] setFont: pfont];
CGFloat itemHeight = lround([pfont ascender] - [pfont descender]);
diff --git a/cocoa/QuartzTextStyle.h b/cocoa/QuartzTextStyle.h
index 51d03cf91..faffe7616 100644
--- a/cocoa/QuartzTextStyle.h
+++ b/cocoa/QuartzTextStyle.h
@@ -23,6 +23,18 @@ public:
characterSet = 0;
}
+ QuartzTextStyle(const QuartzTextStyle &other)
+ {
+ // Does not copy font colour attribute
+ fontRef = static_cast<CTFontRef>(CFRetain(other.fontRef));
+ styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef);
+ characterSet = other.characterSet;
+ }
+
+
~QuartzTextStyle()
{
if (styleDict != NULL)