diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-11-13 21:09:23 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-11-13 21:13:46 +0000 |
commit | 64f3c4fe478f0e2478fead92506f592d5401bf33 (patch) | |
tree | c019a8b0276c5b093c3e8c149469f85228dc3cfa | |
parent | 900b202bb6a9e79c51327a8a157d04241ce4fdf3 (diff) |
coverity#1251591 Resource leak
Change-Id: Ieab948d11da7f56b2273637ff3caaefec86030d1
-rw-r--r-- | vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx index 24732979b94e..9c11cd914940 100644 --- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx @@ -870,7 +870,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, clipList aClip; GdkDrawable* gdkDrawable = GDK_DRAWABLE( GetGdkWindow() ); - GdkX11Pixmap* pixmap = NULL; + std::unique_ptr<GdkX11Pixmap> xPixmap; Rectangle aPixmapRect; if( ( bNeedPixmapPaint ) && nType != CTRL_SCROLLBAR @@ -885,10 +885,10 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, // outside the rectangle, see e.g. checkbox aPixmapRect = Rectangle( Point( aCtrlRect.Left()-1, aCtrlRect.Top()-1 ), Size( aCtrlRect.GetWidth()+2, aCtrlRect.GetHeight()+2) ); - pixmap = NWGetPixmapFromScreen( aPixmapRect ); - if( ! pixmap ) + xPixmap.reset(NWGetPixmapFromScreen(aPixmapRect)); + if (!xPixmap) return false; - gdkDrawable = pixmap->GetGdkDrawable(); + gdkDrawable = xPixmap->GetGdkDrawable(); aCtrlRect = Rectangle( Point(1,1), aCtrlRect.GetSize() ); aClip.push_back( aCtrlRect ); } @@ -1022,10 +1022,9 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, returnVal = NWPaintGTKArrow( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption ); } - if( pixmap ) + if( xPixmap ) { - returnVal = NWRenderPixmapToScreen( pixmap, aPixmapRect ) && returnVal; - delete pixmap; + returnVal = NWRenderPixmapToScreen(xPixmap.get(), aPixmapRect) && returnVal; } return( returnVal ); |