From 45905b9b773c9a43a765373ef11f451dc5dcd94a Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 13 Oct 2003 19:31:56 +0000 Subject: using auto_ptr --- src/FbTk/KeyUtil.cc | 14 +++++++------- src/FbTk/KeyUtil.hh | 8 +++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/FbTk/KeyUtil.cc b/src/FbTk/KeyUtil.cc index 71dc22a..72e78eb 100644 --- a/src/FbTk/KeyUtil.cc +++ b/src/FbTk/KeyUtil.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: KeyUtil.cc,v 1.3 2003/10/05 07:20:16 rathnor Exp $ +// $Id: KeyUtil.cc,v 1.4 2003/10/13 19:31:56 fluxgen Exp $ #include "KeyUtil.hh" #include "App.hh" @@ -28,12 +28,12 @@ namespace FbTk { -KeyUtil *KeyUtil::s_keyutil = 0; +std::auto_ptr KeyUtil::s_keyutil; -KeyUtil *KeyUtil::instance() { - if (s_keyutil == 0) - s_keyutil = new KeyUtil(); - return s_keyutil; +KeyUtil &KeyUtil::instance() { + if (s_keyutil.get() == 0) + s_keyutil.reset(new KeyUtil()); + return *s_keyutil.get(); } @@ -170,7 +170,7 @@ void KeyUtil::ungrabKeys() { } unsigned int KeyUtil::keycodeToModmask(unsigned int keycode) { - XModifierKeymap *modmap = instance()->m_modmap; + XModifierKeymap *modmap = instance().m_modmap; if (!modmap) return 0; diff --git a/src/FbTk/KeyUtil.hh b/src/FbTk/KeyUtil.hh index a6051f6..019fbc5 100644 --- a/src/FbTk/KeyUtil.hh +++ b/src/FbTk/KeyUtil.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: KeyUtil.hh,v 1.2 2003/10/05 07:20:35 rathnor Exp $ +// $Id: KeyUtil.hh,v 1.3 2003/10/13 19:31:56 fluxgen Exp $ #ifndef FBTK_KEYUTIL_HH #define FBTK_KEYUTIL_HH @@ -27,6 +27,8 @@ #include #include +#include + namespace FbTk { class KeyUtil { @@ -36,7 +38,7 @@ public: ~KeyUtil(); void init(); - static KeyUtil *instance(); + static KeyUtil &instance(); /** Grab the specified key @@ -78,7 +80,7 @@ private: void loadModmap(); XModifierKeymap *m_modmap; - static KeyUtil *s_keyutil; + static std::auto_ptr s_keyutil; }; } // end namespace FbTk -- cgit v0.11.2