--- a/src/main.cc Wed Jan 08 23:52:25 2014 +0200 +++ b/src/main.cc Fri Jan 10 03:35:50 2014 +0200 @@ -21,6 +21,7 @@ #include <QAbstractButton> #include <QFile> #include <QTextStream> +#include <QDir> #include "gui.h" #include "document.h" #include "misc.h" @@ -35,7 +36,6 @@ QList<LDDocument*> g_loadedFiles; ForgeWindow* g_win = null; -const QApplication* g_app = null; static QString g_versionString, g_fullVersionString; const Vertex g_origin (0.0f, 0.0f, 0.0f); @@ -43,6 +43,18 @@ cfg (Bool, firststart, true); +static QString g_argv0; + +QString getApplicationDirectory() +{ + assert (g_argv0.isEmpty() == false); + + if (g_argv0.indexOf (DIRSLASH) != -1) + return dirname (g_argv0); + + return "."; +} + // ============================================================================= // ----------------------------------------------------------------------------- int main (int argc, char* argv[]) @@ -50,8 +62,7 @@ QApplication app (argc, argv); app.setOrganizationName (APPNAME); app.setApplicationName (APPNAME); - g_app = &app; - + g_argv0 = argv[0]; initCrashCatcher(); LDDocument::setCurrent (null);