]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/scopeguard.h
avoid creating and immediately destroying a wxGraphicsContext when creating a wxDC...
[wxWidgets.git] / include / wx / scopeguard.h
index a68c9896d8bf0cd9dee2ab8c416119acd75a993e..434c89768d58d4ed29d12fe1476e3c15b9630d9e 100644 (file)
@@ -390,7 +390,7 @@ namespace wxPrivate
 {
 
 // empty class just to be able to define a reference to it
-class VariableSetterBase { };
+class VariableSetterBase : public wxScopeGuardImplBase { };
 
 typedef const VariableSetterBase& VariableSetter;
 
@@ -404,10 +404,9 @@ public:
     {
     }
 
-    ~VariableSetterImpl()
-    {
-        m_var = m_value;
-    }
+    ~VariableSetterImpl() { wxPrivateOnScopeExit(*this); }
+
+    void Execute() { m_var = m_value; }
 
 private:
     T& m_var;
@@ -426,10 +425,9 @@ public:
     {
     }
 
-    ~VariableNullerImpl()
-    {
-        m_var = NULL;
-    }
+    ~VariableNullerImpl() { wxPrivateOnScopeExit(*this); }
+
+    void Execute() { m_var = NULL; }
 
 private:
     T& m_var;