]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dcbase.cpp
no real changes, just rename the variables to make the code more readable and to...
[wxWidgets.git] / src / common / dcbase.cpp
index d698009c316fe755d4ea235d8a277c7b189255e7..415b71763a961fbec886fb005e94891e153a87ea 100644 (file)
@@ -30,6 +30,7 @@
 #include "wx/dcscreen.h"
 #include "wx/dcprint.h"
 #include "wx/prntbase.h"
 #include "wx/dcscreen.h"
 #include "wx/dcprint.h"
 #include "wx/prntbase.h"
+#include "wx/scopeguard.h"
 
 #ifndef WX_PRECOMP
     #include "wx/math.h"
 
 #ifndef WX_PRECOMP
     #include "wx/math.h"
@@ -1054,8 +1055,9 @@ void wxDCImpl::DoGradientFillConcentric(const wxRect& rect,
                                       const wxColour& destColour,
                                       const wxPoint& circleCenter)
 {
                                       const wxColour& destColour,
                                       const wxPoint& circleCenter)
 {
-    //save the old pen color
-    wxColour oldPenColour = m_pen.GetColour();
+    // save the old pen and ensure it is restored on exit
+    const wxPen penOrig = m_pen;
+    wxON_BLOCK_EXIT_SET(m_pen, penOrig);
 
     wxUint8 nR1 = destColour.Red();
     wxUint8 nG1 = destColour.Green();
 
     wxUint8 nR1 = destColour.Red();
     wxUint8 nG1 = destColour.Green();
@@ -1100,12 +1102,10 @@ void wxDCImpl::DoGradientFillConcentric(const wxRect& rect,
             nB = (wxUint8)(nB1 + ((nB2 - nB1) * nGradient / 100));
 
             //set the pixel
             nB = (wxUint8)(nB1 + ((nB2 - nB1) * nGradient / 100));
 
             //set the pixel
-            m_pen.SetColour(wxColour(nR,nG,nB));
+            m_pen = wxColour(nR,nG,nB);
             DoDrawPoint(x + rect.GetLeft(), y + rect.GetTop());
         }
     }
             DoDrawPoint(x + rect.GetLeft(), y + rect.GetTop());
         }
     }
-    //return old pen color
-    m_pen.SetColour(oldPenColour);
 }
 
 void wxDCImpl::InheritAttributes(wxWindow *win)
 }
 
 void wxDCImpl::InheritAttributes(wxWindow *win)