using auto_ptr

This commit is contained in:
fluxgen 2003-10-13 19:31:56 +00:00
parent ea61aa6480
commit 45905b9b77
2 changed files with 12 additions and 10 deletions

View file

@ -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> 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;

View file

@ -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 <X11/Xlib.h>
#include <X11/keysym.h>
#include <memory>
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<KeyUtil> s_keyutil;
};
} // end namespace FbTk