comparison mde/scheduler/Init.d @ 45:0fd51d2c6c8a

Several changes to resising windows and layout widgets. This commit still has some bugs. Moved the implementable widgets from mde.gui.widget.Widget to miscWidgets, leaving base widgets in Widget. Rewrote some of GridLayoutWidget's implementation. Made many operations general to work for either columns or rows. Some optimisations were intended but ended up being removed due to problems. Allowed layout's to resize from either direction (only with window resizes). committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 22 May 2008 11:34:09 +0100
parents 1530d9c04d4d
children f000d6cd0f74
comparison
equal deleted inserted replaced
44:07bd1a09e161 45:0fd51d2c6c8a
210 210
211 const LOG_IF_MSG = "Init function "; 211 const LOG_IF_MSG = "Init function ";
212 const LOG_CF_MSG = "Cleanup function "; 212 const LOG_CF_MSG = "Cleanup function ";
213 const LOG_F_START = " - running"; 213 const LOG_F_START = " - running";
214 const LOG_F_END = " - completed"; 214 const LOG_F_END = " - completed";
215 const LOG_F_BAD = " - failed";
215 const LOG_F_FAIL = " - failed: "; 216 const LOG_F_FAIL = " - failed: ";
216 /* Runs all functions consecutively, first-to-last. 217 /* Runs all functions consecutively, first-to-last.
217 * If any function fails, halts immediately. */ 218 * If any function fails, halts immediately. */
218 void runStageForward (InitStage s) { 219 void runStageForward (InitStage s) {
219 foreach (func; s.funcs) { 220 foreach (func; s.funcs) {
220 if (initFailure) break; 221 if (initFailure) break;
221 try { 222 try {
222 debug logger.trace (LOG_IF_MSG ~ func.name ~ LOG_F_START); 223 debug logger.trace (LOG_IF_MSG ~ func.name ~ LOG_F_START);
223 func.func(); 224 func.func();
224 debug logger.trace (LOG_IF_MSG ~ func.name ~ LOG_F_END); 225 debug logger.trace (LOG_IF_MSG ~ func.name ~ (initFailure ? LOG_F_BAD : LOG_F_END));
225 } catch (Exception e) { 226 } catch (Exception e) {
226 logger.fatal (LOG_IF_MSG ~ func.name ~ LOG_F_FAIL ~ 227 logger.fatal (LOG_IF_MSG ~ func.name ~ LOG_F_FAIL ~
227 ((e.msg is null || e.msg == "") ? "(no failure message)" : e.msg) ); 228 ((e.msg is null || e.msg == "") ? "(no failure message)" : e.msg) );
228 229
229 setInitFailure(); 230 setInitFailure();
237 void runStageReverse (InitStage s) { 238 void runStageReverse (InitStage s) {
238 foreach_reverse (func; s.funcs) { 239 foreach_reverse (func; s.funcs) {
239 try { 240 try {
240 debug logger.trace (LOG_CF_MSG ~ func.name ~ LOG_F_START); 241 debug logger.trace (LOG_CF_MSG ~ func.name ~ LOG_F_START);
241 func.func(); 242 func.func();
242 debug logger.trace (LOG_CF_MSG ~ func.name ~ LOG_F_END); 243 debug logger.trace (LOG_CF_MSG ~ func.name ~ (initFailure ? LOG_F_BAD : LOG_F_END));
243 } catch (Exception e) { 244 } catch (Exception e) {
244 logger.fatal (LOG_CF_MSG ~ func.name ~ LOG_F_FAIL ~ 245 logger.fatal (LOG_CF_MSG ~ func.name ~ LOG_F_FAIL ~
245 ((e.msg is null || e.msg == "") ? "(no failure message)" : e.msg) ); 246 ((e.msg is null || e.msg == "") ? "(no failure message)" : e.msg) );
246 247
247 setInitFailure(); 248 setInitFailure();
258 try { // creating/starting threads could fail 259 try { // creating/starting threads could fail
259 tg = new ThreadGroup; 260 tg = new ThreadGroup;
260 foreach (func; s.funcs) { // Start all threads 261 foreach (func; s.funcs) { // Start all threads
261 debug logger.trace (LOG_IF_MSG ~ func.name ~ LOG_F_START); 262 debug logger.trace (LOG_IF_MSG ~ func.name ~ LOG_F_START);
262 tg.create(func.func); 263 tg.create(func.func);
263 debug logger.trace (LOG_IF_MSG ~ func.name ~ LOG_F_END); 264 debug logger.trace (LOG_IF_MSG ~ func.name ~ (initFailure ? LOG_F_BAD : LOG_F_END));
264 } 265 }
265 } catch (ThreadException e) { // Problem with threading; try without threads 266 } catch (ThreadException e) { // Problem with threading; try without threads
266 logger.error ("Caught ThreadException while trying to create threads:"); 267 logger.error ("Caught ThreadException while trying to create threads:");
267 logger.error (e.msg); 268 logger.error (e.msg);
268 logger.info ("Will disable threads and continue, assuming no threads were created."); 269 logger.info ("Will disable threads and continue, assuming no threads were created.");