28 #include "colors.h" |
28 #include "colors.h" |
29 #include "types.h" |
29 #include "types.h" |
30 #include "primitives.h" |
30 #include "primitives.h" |
31 #include "gldraw.h" |
31 #include "gldraw.h" |
32 #include "configDialog.h" |
32 #include "configDialog.h" |
|
33 #include "dialogs.h" |
|
34 #include "crashcatcher.h" |
33 |
35 |
34 QList<LDFile*> g_loadedFiles; |
36 QList<LDFile*> g_loadedFiles; |
35 ForgeWindow* g_win = null; |
37 ForgeWindow* g_win = null; |
36 const QApplication* g_app = null; |
38 const QApplication* g_app = null; |
37 File g_file_stdout (stdout, File::Write); |
39 File g_file_stdout (stdout, File::Write); |
47 // ----------------------------------------------------------------------------- |
49 // ----------------------------------------------------------------------------- |
48 int main (int argc, char* argv[]) |
50 int main (int argc, char* argv[]) |
49 { QApplication app (argc, argv); |
51 { QApplication app (argc, argv); |
50 app.setOrganizationName (APPNAME); |
52 app.setOrganizationName (APPNAME); |
51 app.setApplicationName (APPNAME); |
53 app.setApplicationName (APPNAME); |
|
54 g_app = &app; |
52 |
55 |
53 g_app = &app; |
56 initCrashCatcher(); |
54 LDFile::setCurrent (null); |
57 LDFile::setCurrent (null); |
55 |
58 |
56 // Load or create the configuration |
59 // Load or create the configuration |
57 if (!Config::load()) |
60 if (!Config::load()) |
58 { print ("Creating configuration file...\n"); |
61 { log ("Creating configuration file...\n"); |
59 |
62 |
60 if (Config::save()) |
63 if (Config::save()) |
61 print ("Configuration file successfully created.\n"); |
64 log ("Configuration file successfully created.\n"); |
62 else |
65 else |
63 print ("failed to create configuration file!\n"); |
66 log ("failed to create configuration file!\n"); |
64 } |
67 } |
65 |
68 |
66 LDPaths::initPaths(); |
69 LDPaths::initPaths(); |
67 initColors(); |
70 initColors(); |
68 loadLogoedStuds(); |
71 loadLogoedStuds(); |
134 // ============================================================================= |
137 // ============================================================================= |
135 // ----------------------------------------------------------------------------- |
138 // ----------------------------------------------------------------------------- |
136 QString fullVersionString() |
139 QString fullVersionString() |
137 { return fmt ("v%1 %2", versionString(), versionMoniker()); |
140 { return fmt ("v%1 %2", versionString(), versionMoniker()); |
138 } |
141 } |
139 |
|
140 // ============================================================================= |
|
141 // ----------------------------------------------------------------------------- |
|
142 void assertionFailure (const char* file, int line, const char* funcname, const char* expr) |
|
143 { str errmsg = fmt ("File: %1\nLine: %2:\nFunction %3:\n\nAssertion `%4' failed", |
|
144 file, line, funcname, expr); |
|
145 |
|
146 #ifndef RELEASE |
|
147 errmsg += ", aborting."; |
|
148 #else |
|
149 errmsg += "."; |
|
150 #endif |
|
151 |
|
152 printf ("%s\n", errmsg.toStdString().c_str()); |
|
153 |
|
154 #ifndef RELEASE |
|
155 if (g_win) |
|
156 g_win->deleteLater(); |
|
157 |
|
158 errmsg.replace ("\n", "<br />"); |
|
159 |
|
160 QMessageBox box (null); |
|
161 const QMessageBox::StandardButton btn = QMessageBox::Close; |
|
162 box.setWindowTitle ("Fatal Error"); |
|
163 box.setIconPixmap (getIcon ("bomb")); |
|
164 box.setWindowIcon (getIcon ("ldforge")); |
|
165 box.setText (errmsg); |
|
166 box.addButton (btn); |
|
167 box.button (btn)->setText ("Damn it"); |
|
168 box.setDefaultButton (btn); |
|
169 box.exec(); |
|
170 abort(); |
|
171 #endif |
|
172 } |
|