all repos — fluxbox @ 45905b9b773c9a43a765373ef11f451dc5dcd94a

custom fork of the fluxbox windowmanager

using auto_ptr
fluxgen fluxgen
commit

45905b9b773c9a43a765373ef11f451dc5dcd94a

parent

ea61aa6480fa1ebc9bd8be330fe9d6ee70a963eb

2 files changed, 12 insertions(+), 10 deletions(-)

jump to
M src/FbTk/KeyUtil.ccsrc/FbTk/KeyUtil.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 @@ #include <string>

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

} unsigned int KeyUtil::keycodeToModmask(unsigned int keycode) { - XModifierKeymap *modmap = instance()->m_modmap; + XModifierKeymap *modmap = instance().m_modmap; if (!modmap) return 0;
M src/FbTk/KeyUtil.hhsrc/FbTk/KeyUtil.hh

@@ -19,13 +19,15 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 #include <X11/Xlib.h> #include <X11/keysym.h> + +#include <memory> namespace FbTk {

@@ -36,7 +38,7 @@ KeyUtil();

~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