diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2009-10-01 05:07:07 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2009-10-01 05:07:07 (GMT) |
commit | 38ef6e515589af7841c577188eb23c5dbe5d11f3 (patch) | |
tree | 43cea3086cddfb59c7bfb8ea1e05e7ec93910280 /src | |
parent | 69de5b5a00abf131452a8d5153afd0df6e86ce6c (diff) | |
download | fluxbox_lack-38ef6e515589af7841c577188eb23c5dbe5d11f3.zip fluxbox_lack-38ef6e515589af7841c577188eb23c5dbe5d11f3.tar.bz2 |
made code simpler
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Resource.cc | 14 | ||||
-rw-r--r-- | src/FbTk/Resource.hh | 9 |
2 files changed, 7 insertions, 16 deletions
diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc index 94b31b2..4be85de 100644 --- a/src/FbTk/Resource.cc +++ b/src/FbTk/Resource.cc | |||
@@ -42,7 +42,11 @@ ResourceManager::ResourceManager(const char *filename, bool lock_db) : | |||
42 | m_database(0), | 42 | m_database(0), |
43 | m_filename(filename ? filename : "") | 43 | m_filename(filename ? filename : "") |
44 | { | 44 | { |
45 | ensureXrmIsInitialize(); | 45 | static bool xrm_initialized = false; |
46 | if (!xrm_initialized) { | ||
47 | XrmInitialize(); | ||
48 | xrm_initialized = true; | ||
49 | } | ||
46 | 50 | ||
47 | if (lock_db) | 51 | if (lock_db) |
48 | lock(); | 52 | lock(); |
@@ -53,7 +57,6 @@ ResourceManager::~ResourceManager() { | |||
53 | delete m_database; | 57 | delete m_database; |
54 | } | 58 | } |
55 | 59 | ||
56 | bool ResourceManager::m_init = false; | ||
57 | 60 | ||
58 | /** | 61 | /** |
59 | reloads all resources from resourcefile | 62 | reloads all resources from resourcefile |
@@ -198,13 +201,6 @@ void ResourceManager::setResourceValue(const string &resname, const string &valu | |||
198 | 201 | ||
199 | } | 202 | } |
200 | 203 | ||
201 | void ResourceManager::ensureXrmIsInitialize() { | ||
202 | if (!m_init) { | ||
203 | XrmInitialize(); | ||
204 | m_init = true; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | ResourceManager &ResourceManager::lock() { | 204 | ResourceManager &ResourceManager::lock() { |
209 | ++m_db_lock; | 205 | ++m_db_lock; |
210 | // if the lock was zero, then load the database | 206 | // if the lock was zero, then load the database |
diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh index bfdcdca..8c9d645 100644 --- a/src/FbTk/Resource.hh +++ b/src/FbTk/Resource.hh | |||
@@ -139,12 +139,10 @@ public: | |||
139 | } | 139 | } |
140 | } | 140 | } |
141 | protected: | 141 | protected: |
142 | static void ensureXrmIsInitialize(); | ||
143 | 142 | ||
144 | int m_db_lock; | 143 | int m_db_lock; |
145 | 144 | ||
146 | private: | 145 | private: |
147 | static bool m_init; | ||
148 | 146 | ||
149 | ResourceList m_resourcelist; | 147 | ResourceList m_resourcelist; |
150 | 148 | ||
@@ -168,11 +166,8 @@ template <typename T> | |||
168 | class Resource:public Resource_base, public Accessor<T> { | 166 | class Resource:public Resource_base, public Accessor<T> { |
169 | public: | 167 | public: |
170 | typedef T Type; | 168 | typedef T Type; |
171 | Resource(ResourceManager &rm, T val, | 169 | Resource(ResourceManager &rm, T val, const std::string &name, const std::string &altname): |
172 | const std::string &name, const std::string &altname): | 170 | Resource_base(name, altname), m_value(val), m_defaultval(val), m_rm(rm) { |
173 | Resource_base(name, altname), | ||
174 | m_value(val), m_defaultval(val), | ||
175 | m_rm(rm) { | ||
176 | m_rm.addResource(*this); // add this to resource handler | 171 | m_rm.addResource(*this); // add this to resource handler |
177 | } | 172 | } |
178 | virtual ~Resource() { | 173 | virtual ~Resource() { |