diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-08-04 09:02:04 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2013-02-18 21:04:25 (GMT) |
commit | 66cc0caf41cde33df4fcad250322ef744a1b234b (patch) | |
tree | 49834634301b8a3a38a871fd44493c4f011f4af5 | |
parent | d9be60362f364145daeaa21dcea99d0fff4c1203 (diff) | |
download | fluxbox_pavel-66cc0caf41cde33df4fcad250322ef744a1b234b.zip fluxbox_pavel-66cc0caf41cde33df4fcad250322ef744a1b234b.tar.bz2 |
Move most of the resource loading code into ResourceManager_base
I mostly do this to avoid code duplication between fluxbox and fluxbox-update_configs.
-rw-r--r-- | src/FbTk/LResource.cc | 30 | ||||
-rw-r--r-- | src/FbTk/LResource.hh | 3 | ||||
-rw-r--r-- | src/FbTk/Resource.cc | 39 | ||||
-rw-r--r-- | src/FbTk/Resource.hh | 15 | ||||
-rw-r--r-- | src/fluxbox.cc | 8 | ||||
-rw-r--r-- | util/fluxbox-update_configs.cc | 45 |
6 files changed, 73 insertions, 67 deletions
diff --git a/src/FbTk/LResource.cc b/src/FbTk/LResource.cc index de90b95..18209cb 100644 --- a/src/FbTk/LResource.cc +++ b/src/FbTk/LResource.cc | |||
@@ -116,34 +116,12 @@ LResourceManager::LResourceManager(const std::string &root, Lua &l, unsigned int | |||
116 | setLua(l); | 116 | setLua(l); |
117 | } | 117 | } |
118 | 118 | ||
119 | void LResourceManager::load(const std::string &filename, const std::string &fallback) { | 119 | void LResourceManager::doLoad(const std::string &filename) { |
120 | _FB_USES_NLS; | ||
121 | m_l->checkstack(1); | 120 | m_l->checkstack(1); |
122 | lua::stack_sentry s(*m_l); | 121 | lua::stack_sentry s(*m_l); |
123 | 122 | ||
124 | m_filename = filename; | 123 | m_l->loadfile(filename.c_str()); |
125 | 124 | m_l->call(0, 0); | |
126 | try { | ||
127 | m_l->loadfile(filename.c_str()); | ||
128 | m_l->call(0, 0); | ||
129 | } | ||
130 | catch(lua::exception &e) { | ||
131 | std::cerr << _FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", | ||
132 | "Failed trying to read rc file") << ":" << filename << std::endl; | ||
133 | std::cerr << "Fluxbox: " << e.what() << std::endl; | ||
134 | std::cerr << _FB_CONSOLETEXT(Fluxbox, CantLoadRCFileTrying, "Retrying with", | ||
135 | "Retrying rc file loading with (the following file)") | ||
136 | << ": " << fallback << std::endl; | ||
137 | try { | ||
138 | m_l->loadfile(fallback.c_str()); | ||
139 | m_l->call(0, 0); | ||
140 | } | ||
141 | catch(lua::exception &e) { | ||
142 | std::cerr << _FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "") | ||
143 | << ": " << fallback << std::endl; | ||
144 | std::cerr << "Fluxbox: " << e.what() << std::endl; | ||
145 | } | ||
146 | } | ||
147 | } | 125 | } |
148 | 126 | ||
149 | bool LResourceManager::save(const char *filename, const char *) { | 127 | bool LResourceManager::save(const char *filename, const char *) { |
@@ -153,8 +131,6 @@ bool LResourceManager::save(const char *filename, const char *) { | |||
153 | if(filename == NULL) | 131 | if(filename == NULL) |
154 | filename = m_filename.c_str(); | 132 | filename = m_filename.c_str(); |
155 | 133 | ||
156 | std::cerr << "XXX SAVING " << filename << std::endl; | ||
157 | |||
158 | m_l->getfield(lua::REGISTRYINDEX, dump_resources); | 134 | m_l->getfield(lua::REGISTRYINDEX, dump_resources); |
159 | m_l->getfield(lua::GLOBALSINDEX, m_root.c_str()); | 135 | m_l->getfield(lua::GLOBALSINDEX, m_root.c_str()); |
160 | m_l->pushstring(filename); | 136 | m_l->pushstring(filename); |
diff --git a/src/FbTk/LResource.hh b/src/FbTk/LResource.hh index 30f0e02..a198197 100644 --- a/src/FbTk/LResource.hh +++ b/src/FbTk/LResource.hh | |||
@@ -45,7 +45,6 @@ public: | |||
45 | * starts a timer. If another resource is modified, the timer is restarted. 0 = disabled | 45 | * starts a timer. If another resource is modified, the timer is restarted. 0 = disabled |
46 | */ | 46 | */ |
47 | LResourceManager(const std::string &root, Lua &l, unsigned int autosave = 0); | 47 | LResourceManager(const std::string &root, Lua &l, unsigned int autosave = 0); |
48 | void load(const std::string &filename, const std::string &fallback); | ||
49 | virtual bool save(const char *filename, const char *); | 48 | virtual bool save(const char *filename, const char *); |
50 | virtual void addResource(Resource_base &r); | 49 | virtual void addResource(Resource_base &r); |
51 | virtual void removeResource(Resource_base &r); | 50 | virtual void removeResource(Resource_base &r); |
@@ -55,9 +54,9 @@ public: | |||
55 | private: | 54 | private: |
56 | void doAddResource(Resource_base &r); | 55 | void doAddResource(Resource_base &r); |
57 | void doRemoveResource(Resource_base &r); | 56 | void doRemoveResource(Resource_base &r); |
57 | virtual void doLoad(const std::string &filename); | ||
58 | 58 | ||
59 | Lua *m_l; | 59 | Lua *m_l; |
60 | std::string m_filename; | ||
61 | Timer m_savetimer; | 60 | Timer m_savetimer; |
62 | }; | 61 | }; |
63 | 62 | ||
diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc index 37555b3..8f63322 100644 --- a/src/FbTk/Resource.cc +++ b/src/FbTk/Resource.cc | |||
@@ -38,6 +38,33 @@ using std::string; | |||
38 | namespace FbTk { | 38 | namespace FbTk { |
39 | 39 | ||
40 | 40 | ||
41 | void ResourceManager_base::load(const std::string &filename, const std::string &fallback) { | ||
42 | _FB_USES_NLS; | ||
43 | |||
44 | m_filename = filename; | ||
45 | |||
46 | try { | ||
47 | doLoad(filename); | ||
48 | } | ||
49 | catch(std::runtime_error &e) { | ||
50 | std::cerr << _FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", | ||
51 | "Failed trying to read rc file") << ":" << filename << std::endl; | ||
52 | std::cerr << "Fluxbox: " << e.what() << std::endl; | ||
53 | std::cerr << _FB_CONSOLETEXT(Fluxbox, CantLoadRCFileTrying, "Retrying with", | ||
54 | "Retrying rc file loading with (the following file)") | ||
55 | << ": " << fallback << std::endl; | ||
56 | try { | ||
57 | doLoad(fallback); | ||
58 | } | ||
59 | catch(std::runtime_error &e) { | ||
60 | std::cerr << _FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "") | ||
61 | << ": " << fallback << std::endl; | ||
62 | std::cerr << "Fluxbox: " << e.what() << std::endl; | ||
63 | throw; | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | |||
41 | void ResourceManager_base::addResource(Resource_base &r) { | 68 | void ResourceManager_base::addResource(Resource_base &r) { |
42 | m_resourcelist.push_back(&r); | 69 | m_resourcelist.push_back(&r); |
43 | m_resourcelist.unique(); | 70 | m_resourcelist.unique(); |
@@ -87,7 +114,6 @@ ResourceManager::ResourceManager(const std::string &root, const std::string &alt | |||
87 | ResourceManager_base(root), | 114 | ResourceManager_base(root), |
88 | m_db_lock(0), | 115 | m_db_lock(0), |
89 | m_database(0), | 116 | m_database(0), |
90 | m_filename(filename ? filename : ""), | ||
91 | m_alt_root(alt_root) | 117 | m_alt_root(alt_root) |
92 | { | 118 | { |
93 | static bool xrm_initialized = false; | 119 | static bool xrm_initialized = false; |
@@ -96,6 +122,7 @@ ResourceManager::ResourceManager(const std::string &root, const std::string &alt | |||
96 | xrm_initialized = true; | 122 | xrm_initialized = true; |
97 | } | 123 | } |
98 | 124 | ||
125 | m_filename = filename ? filename : ""; | ||
99 | if (lock_db) | 126 | if (lock_db) |
100 | lock(); | 127 | lock(); |
101 | } | 128 | } |
@@ -108,11 +135,9 @@ ResourceManager::~ResourceManager() { | |||
108 | 135 | ||
109 | /** | 136 | /** |
110 | reloads all resources from resourcefile | 137 | reloads all resources from resourcefile |
111 | @return true on success else false | 138 | throws an exception in case of failure |
112 | */ | 139 | */ |
113 | bool ResourceManager::load(const char *filename) { | 140 | void ResourceManager::doLoad(const std::string &filename) { |
114 | m_filename = StringUtil::expandFilename(filename).c_str(); | ||
115 | |||
116 | // force reload (lock will ensure it exists) | 141 | // force reload (lock will ensure it exists) |
117 | if (m_database) { | 142 | if (m_database) { |
118 | delete m_database; | 143 | delete m_database; |
@@ -122,7 +147,7 @@ bool ResourceManager::load(const char *filename) { | |||
122 | lock(); | 147 | lock(); |
123 | if (!m_database) { | 148 | if (!m_database) { |
124 | unlock(); | 149 | unlock(); |
125 | return false; | 150 | throw std::runtime_error(""); |
126 | } | 151 | } |
127 | 152 | ||
128 | XrmValue value; | 153 | XrmValue value; |
@@ -146,8 +171,6 @@ bool ResourceManager::load(const char *filename) { | |||
146 | } | 171 | } |
147 | 172 | ||
148 | unlock(); | 173 | unlock(); |
149 | |||
150 | return true; | ||
151 | } | 174 | } |
152 | 175 | ||
153 | /** | 176 | /** |
diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh index c4a7951..700fe70 100644 --- a/src/FbTk/Resource.hh +++ b/src/FbTk/Resource.hh | |||
@@ -92,6 +92,11 @@ public: | |||
92 | 92 | ||
93 | virtual ~ResourceManager_base() {} | 93 | virtual ~ResourceManager_base() {} |
94 | 94 | ||
95 | /// Load all resources registered to this class | ||
96 | /// if loading of filename fails, it tries to load fallback | ||
97 | /// if that fails, it throws an exception | ||
98 | void load(const std::string &filename, const std::string &fallback); | ||
99 | |||
95 | /// Save all resouces registered to this class | 100 | /// Save all resouces registered to this class |
96 | /// @return true on success | 101 | /// @return true on success |
97 | virtual bool save(const char *filename, const char *mergefilename=0) = 0; | 102 | virtual bool save(const char *filename, const char *mergefilename=0) = 0; |
@@ -130,8 +135,12 @@ public: | |||
130 | ResourceList::const_iterator end() { return m_resourcelist.end(); } | 135 | ResourceList::const_iterator end() { return m_resourcelist.end(); } |
131 | 136 | ||
132 | protected: | 137 | protected: |
138 | /// does the actual loading | ||
139 | virtual void doLoad(const std::string &filename) = 0; | ||
140 | |||
133 | ResourceList m_resourcelist; | 141 | ResourceList m_resourcelist; |
134 | const std::string m_root; | 142 | const std::string m_root; |
143 | std::string m_filename; | ||
135 | }; | 144 | }; |
136 | 145 | ||
137 | class ResourceManager: public ResourceManager_base | 146 | class ResourceManager: public ResourceManager_base |
@@ -143,10 +152,6 @@ public: | |||
143 | const char *filename, bool lock_db); | 152 | const char *filename, bool lock_db); |
144 | virtual ~ResourceManager(); | 153 | virtual ~ResourceManager(); |
145 | 154 | ||
146 | /// Load all resources registered to this class | ||
147 | /// @return true on success | ||
148 | virtual bool load(const char *filename); | ||
149 | |||
150 | /// Save all resouces registered to this class | 155 | /// Save all resouces registered to this class |
151 | /// @return true on success | 156 | /// @return true on success |
152 | virtual bool save(const char *filename, const char *mergefilename=0); | 157 | virtual bool save(const char *filename, const char *mergefilename=0); |
@@ -173,6 +178,7 @@ public: | |||
173 | } | 178 | } |
174 | } | 179 | } |
175 | protected: | 180 | protected: |
181 | virtual void doLoad(const std::string &filename); | ||
176 | 182 | ||
177 | int m_db_lock; | 183 | int m_db_lock; |
178 | 184 | ||
@@ -180,7 +186,6 @@ private: | |||
180 | 186 | ||
181 | XrmDatabaseHelper *m_database; | 187 | XrmDatabaseHelper *m_database; |
182 | 188 | ||
183 | std::string m_filename; | ||
184 | std::string m_alt_root; | 189 | std::string m_alt_root; |
185 | }; | 190 | }; |
186 | 191 | ||
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 0cfcd41..a439408 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -1159,7 +1159,13 @@ string Fluxbox::getDefaultDataFilename(const char *name) const { | |||
1159 | /// loads resources | 1159 | /// loads resources |
1160 | void Fluxbox::load_rc() { | 1160 | void Fluxbox::load_rc() { |
1161 | 1161 | ||
1162 | m_resourcemanager.load(getRcFilename(), DEFAULT_INITFILE); | 1162 | try { |
1163 | m_resourcemanager.load(getRcFilename(), DEFAULT_INITFILE); | ||
1164 | } | ||
1165 | catch(std::runtime_error &) { | ||
1166 | // This should only happen if system-wide init file is broken. | ||
1167 | // Not much we can do about that, so we just ignore it | ||
1168 | } | ||
1163 | 1169 | ||
1164 | if (m_rc_menufile->empty()) | 1170 | if (m_rc_menufile->empty()) |
1165 | m_rc_menufile.setDefaultValue(); | 1171 | m_rc_menufile.setDefaultValue(); |
diff --git a/util/fluxbox-update_configs.cc b/util/fluxbox-update_configs.cc index 9062b57..cbc0d73 100644 --- a/util/fluxbox-update_configs.cc +++ b/util/fluxbox-update_configs.cc | |||
@@ -74,7 +74,7 @@ void save_all_files(); | |||
74 | /*------------------------------------------------------------------*\ | 74 | /*------------------------------------------------------------------*\ |
75 | \*------------------------------------------------------------------*/ | 75 | \*------------------------------------------------------------------*/ |
76 | 76 | ||
77 | void update_add_mouse_evens_to_keys(FbTk::ResourceManager& rm, | 77 | void update_add_mouse_evens_to_keys(FbTk::ResourceManager_base& rm, |
78 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 78 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
79 | 79 | ||
80 | string whole_keyfile = read_file(keyfilename); | 80 | string whole_keyfile = read_file(keyfilename); |
@@ -111,7 +111,7 @@ void update_add_mouse_evens_to_keys(FbTk::ResourceManager& rm, | |||
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | void update_move_groups_entries_to_apps_file(FbTk::ResourceManager& rm, | 114 | void update_move_groups_entries_to_apps_file(FbTk::ResourceManager_base& rm, |
115 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 115 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
116 | 116 | ||
117 | FbTk::StringResource rc_groupfile(rm, "~/.fluxbox/groups", | 117 | FbTk::StringResource rc_groupfile(rm, "~/.fluxbox/groups", |
@@ -148,7 +148,7 @@ void update_move_groups_entries_to_apps_file(FbTk::ResourceManager& rm, | |||
148 | } | 148 | } |
149 | 149 | ||
150 | 150 | ||
151 | void update_move_toolbar_wheeling_to_keys_file(FbTk::ResourceManager& rm, | 151 | void update_move_toolbar_wheeling_to_keys_file(FbTk::ResourceManager_base& rm, |
152 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 152 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
153 | 153 | ||
154 | string whole_keyfile = read_file(keyfilename); | 154 | string whole_keyfile = read_file(keyfilename); |
@@ -187,7 +187,7 @@ void update_move_toolbar_wheeling_to_keys_file(FbTk::ResourceManager& rm, | |||
187 | 187 | ||
188 | 188 | ||
189 | 189 | ||
190 | void update_move_modkey_to_keys_file(FbTk::ResourceManager& rm, | 190 | void update_move_modkey_to_keys_file(FbTk::ResourceManager_base& rm, |
191 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 191 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
192 | string whole_keyfile = read_file(keyfilename); | 192 | string whole_keyfile = read_file(keyfilename); |
193 | string new_keyfile = ""; | 193 | string new_keyfile = ""; |
@@ -222,7 +222,7 @@ void update_move_modkey_to_keys_file(FbTk::ResourceManager& rm, | |||
222 | 222 | ||
223 | 223 | ||
224 | 224 | ||
225 | void update_window_patterns_for_iconbar(FbTk::ResourceManager& rm, | 225 | void update_window_patterns_for_iconbar(FbTk::ResourceManager_base& rm, |
226 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 226 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
227 | 227 | ||
228 | // this needs to survive after going out of scope | 228 | // this needs to survive after going out of scope |
@@ -251,7 +251,7 @@ void update_window_patterns_for_iconbar(FbTk::ResourceManager& rm, | |||
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | void update_move_titlebar_actions_to_keys_file(FbTk::ResourceManager& rm, | 254 | void update_move_titlebar_actions_to_keys_file(FbTk::ResourceManager_base& rm, |
255 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 255 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
256 | string whole_keyfile = read_file(keyfilename); | 256 | string whole_keyfile = read_file(keyfilename); |
257 | string new_keyfile = ""; | 257 | string new_keyfile = ""; |
@@ -288,7 +288,7 @@ void update_move_titlebar_actions_to_keys_file(FbTk::ResourceManager& rm, | |||
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | void update_added_starttabbing_command(FbTk::ResourceManager& rm, | 291 | void update_added_starttabbing_command(FbTk::ResourceManager_base& rm, |
292 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 292 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
293 | string whole_keyfile = read_file(keyfilename); | 293 | string whole_keyfile = read_file(keyfilename); |
294 | string new_keyfile = ""; | 294 | string new_keyfile = ""; |
@@ -302,7 +302,7 @@ void update_added_starttabbing_command(FbTk::ResourceManager& rm, | |||
302 | 302 | ||
303 | 303 | ||
304 | 304 | ||
305 | void update_disable_icons_in_tabs_for_backwards_compatibility(FbTk::ResourceManager& rm, | 305 | void update_disable_icons_in_tabs_for_backwards_compatibility(FbTk::ResourceManager_base& rm, |
306 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 306 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
307 | 307 | ||
308 | FbTk::BoolResource *show = | 308 | FbTk::BoolResource *show = |
@@ -316,7 +316,7 @@ void update_disable_icons_in_tabs_for_backwards_compatibility(FbTk::ResourceMana | |||
316 | 316 | ||
317 | 317 | ||
318 | 318 | ||
319 | void update_change_format_of_split_placement_menu(FbTk::ResourceManager& rm, | 319 | void update_change_format_of_split_placement_menu(FbTk::ResourceManager_base& rm, |
320 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 320 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
321 | 321 | ||
322 | FbTk::StringResource *placement = | 322 | FbTk::StringResource *placement = |
@@ -344,7 +344,7 @@ void update_change_format_of_split_placement_menu(FbTk::ResourceManager& rm, | |||
344 | 344 | ||
345 | 345 | ||
346 | 346 | ||
347 | void update_update_keys_file_for_nextwindow_syntax_changes(FbTk::ResourceManager& rm, | 347 | void update_update_keys_file_for_nextwindow_syntax_changes(FbTk::ResourceManager_base& rm, |
348 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 348 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
349 | 349 | ||
350 | string whole_keyfile = read_file(keyfilename); | 350 | string whole_keyfile = read_file(keyfilename); |
@@ -401,7 +401,7 @@ void update_update_keys_file_for_nextwindow_syntax_changes(FbTk::ResourceManager | |||
401 | 401 | ||
402 | 402 | ||
403 | 403 | ||
404 | void update_keys_for_ongrip_onwindowborder(FbTk::ResourceManager& rm, | 404 | void update_keys_for_ongrip_onwindowborder(FbTk::ResourceManager_base& rm, |
405 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 405 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
406 | 406 | ||
407 | string whole_keyfile = read_file(keyfilename); | 407 | string whole_keyfile = read_file(keyfilename); |
@@ -421,7 +421,7 @@ void update_keys_for_ongrip_onwindowborder(FbTk::ResourceManager& rm, | |||
421 | 421 | ||
422 | 422 | ||
423 | 423 | ||
424 | void update_keys_for_activetab(FbTk::ResourceManager& rm, | 424 | void update_keys_for_activetab(FbTk::ResourceManager_base& rm, |
425 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 425 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
426 | 426 | ||
427 | string whole_file = read_file(keyfilename); | 427 | string whole_file = read_file(keyfilename); |
@@ -439,7 +439,7 @@ void update_keys_for_activetab(FbTk::ResourceManager& rm, | |||
439 | 439 | ||
440 | 440 | ||
441 | // NextWindow {static groups} => NextWindow {static groups} (workspace=[current]) | 441 | // NextWindow {static groups} => NextWindow {static groups} (workspace=[current]) |
442 | void update_limit_nextwindow_to_current_workspace(FbTk::ResourceManager& rm, | 442 | void update_limit_nextwindow_to_current_workspace(FbTk::ResourceManager_base& rm, |
443 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { | 443 | const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { |
444 | 444 | ||
445 | string whole_file = read_file(keyfilename); | 445 | string whole_file = read_file(keyfilename); |
@@ -530,7 +530,7 @@ void update_limit_nextwindow_to_current_workspace(FbTk::ResourceManager& rm, | |||
530 | 530 | ||
531 | struct Update { | 531 | struct Update { |
532 | int version; | 532 | int version; |
533 | void (*update)(FbTk::ResourceManager& rm, const FbTk::FbString&, const FbTk::FbString&); | 533 | void (*update)(FbTk::ResourceManager_base& rm, const FbTk::FbString&, const FbTk::FbString&); |
534 | }; | 534 | }; |
535 | 535 | ||
536 | const Update UPDATES[] = { | 536 | const Update UPDATES[] = { |
@@ -618,16 +618,13 @@ int main(int argc, char **argv) { | |||
618 | rc_filename = getenv("HOME") + string("/.fluxbox/init"); | 618 | rc_filename = getenv("HOME") + string("/.fluxbox/init"); |
619 | 619 | ||
620 | FbTk::ResourceManager resource_manager("session", "Session", rc_filename.c_str(),false); | 620 | FbTk::ResourceManager resource_manager("session", "Session", rc_filename.c_str(),false); |
621 | if (!resource_manager.load(rc_filename.c_str())) { | 621 | try { |
622 | // couldn't load rc file | 622 | resource_manager.load(rc_filename, DEFAULT_INITFILE); |
623 | cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "Failed trying to read rc file")<<":"<<rc_filename<<endl; | 623 | } |
624 | cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFileTrying, "Retrying with", "Retrying rc file loading with (the following file)")<<": "<<DEFAULT_INITFILE<<endl; | 624 | catch(std::runtime_error &) { |
625 | 625 | // This should only happen if system-wide init file is broken. | |
626 | // couldn't load default rc file, either | 626 | // this is a fatal error for us |
627 | if (!resource_manager.load(DEFAULT_INITFILE)) { | 627 | return 1; |
628 | cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl; | ||
629 | exit(1); // this is a fatal error for us | ||
630 | } | ||
631 | } | 628 | } |
632 | 629 | ||
633 | // run updates here | 630 | // run updates here |