diff options
| -rw-r--r-- | cocoa/PlatCocoa.mm | 20 | ||||
| -rw-r--r-- | cocoa/ScintillaCocoa.mm | 44 | 
2 files changed, 26 insertions, 38 deletions
| diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 5029947da..761a64463 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1370,18 +1370,14 @@ static NSImage* ImageFromXPM(XPM* pxpm)      const int width = pxpm->GetWidth();      const int height = pxpm->GetHeight();      PRectangle rcxpm(0, 0, width, height); -    Surface* surfaceXPM = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); -    if (surfaceXPM) -    { -      surfaceXPM->InitPixMap(width, height, NULL, NULL); -      SurfaceImpl* surfaceIXPM = static_cast<SurfaceImpl*>(surfaceXPM); -      CGContextClearRect(surfaceIXPM->GetContext(), CGRectMake(0, 0, width, height)); -      pxpm->Draw(surfaceXPM, rcxpm); -      CGImageRef imageRef = surfaceIXPM->GetImage(); -      img = [[NSImage alloc] initWithCGImage:imageRef size: NSZeroSize]; -      CGImageRelease(imageRef); -      delete surfaceXPM; -    } +    std::unique_ptr<Surface> surfaceXPM(Surface::Allocate(SC_TECHNOLOGY_DEFAULT)); +    surfaceXPM->InitPixMap(width, height, NULL, NULL); +    SurfaceImpl* surfaceIXPM = static_cast<SurfaceImpl*>(surfaceXPM.get()); +    CGContextClearRect(surfaceIXPM->GetContext(), CGRectMake(0, 0, width, height)); +    pxpm->Draw(surfaceXPM.get(), rcxpm); +    CGImageRef imageRef = surfaceIXPM->GetImage(); +    img = [[NSImage alloc] initWithCGImage:imageRef size: NSZeroSize]; +    CGImageRelease(imageRef);    }    return img;  } 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)    { | 
