You've already forked lazarus-ccr
richmemo: cocoa, cleanup memory use to prevent crashes
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6473 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -262,6 +262,7 @@ end;
|
||||
function FindFont(const FamilyName: String; astyle: TFontStyles): NSFontDescriptor;
|
||||
var
|
||||
fd : NSFontDescriptor;
|
||||
cfd : NSFontDescriptor;
|
||||
old : NSFontDescriptor;
|
||||
fdd : NSFontDescriptor;
|
||||
trt : NSFontSymbolicTraits;
|
||||
@ -276,18 +277,23 @@ begin
|
||||
if fsBold in aStyle then trt:=trt or NSFontBoldTrait;
|
||||
|
||||
fd:=NSFontDescriptor(NSFontDescriptor.alloc).initWithFontAttributes(nil);
|
||||
fd:=fd.fontDescriptorWithFamily(ns);
|
||||
fd:=fd.fontDescriptorWithSymbolicTraits(trt);
|
||||
|
||||
fdd:=fd.matchingFontDescriptorWithMandatoryKeys(nil);
|
||||
i:=0;
|
||||
while not Assigned(fdd) and (i<length(fallback)) do begin
|
||||
trt:=trt and (not fallback[i]);
|
||||
cfd:=fd;
|
||||
try
|
||||
fd:=fd.fontDescriptorWithFamily(ns);
|
||||
fd:=fd.fontDescriptorWithSymbolicTraits(trt);
|
||||
|
||||
fdd:=fd.matchingFontDescriptorWithMandatoryKeys(nil);
|
||||
i:=0;
|
||||
while not Assigned(fdd) and (i<length(fallback)) do begin
|
||||
trt:=trt and (not fallback[i]);
|
||||
fd:=fd.fontDescriptorWithSymbolicTraits(trt);
|
||||
fdd:=fd.matchingFontDescriptorWithMandatoryKeys(nil);
|
||||
end;
|
||||
Result:=fdd;
|
||||
finally
|
||||
ns.release;
|
||||
cfd.release;
|
||||
end;
|
||||
Result:=fdd;
|
||||
ns.release;
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomRichMemo.SetTextAttributes(
|
||||
@ -314,35 +320,30 @@ begin
|
||||
|
||||
fd:=FindFont(Params.Name, Params.Style);
|
||||
font:=NSFont.fontWithDescriptor_size(fd, Params.Size);
|
||||
|
||||
txt.addAttribute_value_range(NSFontAttributeName, font, rng);
|
||||
// fd.release;
|
||||
|
||||
if fsUnderline in Params.Style then begin
|
||||
num:=NSNumber.numberWithInt(NSUnderlineStyleSingle);
|
||||
txt.addAttribute_value_range(NSUnderlineStyleAttributeName, num, rng);
|
||||
num.release;
|
||||
end else
|
||||
txt.removeAttribute_range(NSUnderlineStyleAttributeName, rng);
|
||||
|
||||
if fsStrikeOut in Params.Style then begin
|
||||
num:=NSNumber.numberWithInt(NSUnderlineStyleSingle);
|
||||
txt.addAttribute_value_range(NSStrikethroughStyleAttributeName, num, rng);
|
||||
num.release;
|
||||
end else
|
||||
txt.removeAttribute_range(NSStrikethroughStyleAttributeName, rng);
|
||||
|
||||
|
||||
clr:=ColorToNSColor(Params.Color);
|
||||
txt.addAttribute_value_range(NSForegroundColorAttributeName, clr, rng);
|
||||
clr.release;
|
||||
|
||||
if Params.HasBkClr then begin
|
||||
clr:=ColorToNSColor(Params.BkColor);
|
||||
txt.addAttribute_value_range(NSBackgroundColorAttributeName, clr, rng);
|
||||
clr.release;
|
||||
end else
|
||||
txt.removeAttribute_range(NSBackgroundColorAttributeName, rng);
|
||||
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomRichMemo.SetParaAlignment(
|
||||
|
Reference in New Issue
Block a user