aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa/ScintillaCocoa.mm
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2017-05-02 10:35:33 +1000
committerNeil <nyamatongwe@gmail.com>2017-05-02 10:35:33 +1000
commitaac6399324495f2dffe8b52c1f4bcfbe931bc3ff (patch)
tree2805eddf2a787288c5b8dd77812648fbff04d92e /cocoa/ScintillaCocoa.mm
parent4d21c4597dd1effe2fa75776c368b4184d9035af (diff)
downloadscintilla-mirror-aac6399324495f2dffe8b52c1f4bcfbe931bc3ff.tar.gz
For Cocoa, use unique_ptr for drawing surfaces and don't check for allocation
failure as that throws an exception.
Diffstat (limited to 'cocoa/ScintillaCocoa.mm')
-rw-r--r--cocoa/ScintillaCocoa.mm44
1 files changed, 18 insertions, 26 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index 505afd4c7..5c89ed765 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -1086,15 +1086,12 @@ void ScintillaCocoa::Paste(bool forceRectangular)
void ScintillaCocoa::CTPaint(void* gc, NSRect rc) {
#pragma unused(rc)
- Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
- if (surfaceWindow) {
- surfaceWindow->Init(gc, wMain.GetID());
- surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ct.codePage);
- surfaceWindow->SetDBCSMode(ct.codePage);
- ct.PaintCT(surfaceWindow);
- surfaceWindow->Release();
- delete surfaceWindow;
- }
+ std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ surfaceWindow->Init(gc, wMain.GetID());
+ surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ct.codePage);
+ surfaceWindow->SetDBCSMode(ct.codePage);
+ ct.PaintCT(surfaceWindow.get());
+ surfaceWindow->Release();
}
@interface CallTipView : NSControl {
@@ -1815,23 +1812,18 @@ bool ScintillaCocoa::SyncPaint(void* gc, PRectangle rc)
rcPaint = rc;
PRectangle rcText = GetTextRectangle();
paintingAllText = rcPaint.Contains(rcText);
- bool succeeded = true;
- Surface *sw = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
- if (sw)
- {
- CGContextSetAllowsAntialiasing((CGContextRef)gc,
- vs.extraFontFlag != SC_EFF_QUALITY_NON_ANTIALIASED);
- CGContextSetAllowsFontSmoothing((CGContextRef)gc,
- vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED);
- CGContextSetAllowsFontSubpixelPositioning((CGContextRef)gc,
- vs.extraFontFlag == SC_EFF_QUALITY_DEFAULT ||
- vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED);
- sw->Init(gc, wMain.GetID());
- Paint(sw, rc);
- succeeded = paintState != paintAbandoned;
- sw->Release();
- delete sw;
- }
+ std::unique_ptr<Surface> sw(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ CGContextSetAllowsAntialiasing((CGContextRef)gc,
+ vs.extraFontFlag != SC_EFF_QUALITY_NON_ANTIALIASED);
+ CGContextSetAllowsFontSmoothing((CGContextRef)gc,
+ vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED);
+ CGContextSetAllowsFontSubpixelPositioning((CGContextRef)gc,
+ vs.extraFontFlag == SC_EFF_QUALITY_DEFAULT ||
+ vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED);
+ sw->Init(gc, wMain.GetID());
+ Paint(sw.get(), rc);
+ const bool succeeded = paintState != paintAbandoned;
+ sw->Release();
paintState = notPainting;
if (!succeeded)
{