diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-05-22 06:35:45 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-05-22 06:36:06 +0200 |
commit | df3728933effcb38162e9167bb17c334e807a9b8 (patch) | |
tree | 26decd0c11c4a5cd3846d2fec61d634bb5f01124 /facetracknoir/main.cpp | |
parent | 296c95ebe47b99d0127dd5131f0e3db18d434dd7 (diff) |
main: allow launching with different working directory
Workaround QTBUG-38598, add program's directory to dynamic modules' path
as a first thing.
Diffstat (limited to 'facetracknoir/main.cpp')
-rw-r--r-- | facetracknoir/main.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 398f293a..e8a29598 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -1,3 +1,7 @@ +#ifdef _WIN32 +# include <stdlib.h> +#endif + #include "ui.h" #include "opentrack/options.hpp" using namespace options; @@ -6,9 +10,35 @@ using namespace options; #include <QStyleFactory> #include <QStringList> #include <memory> +#include <cstring> + +#ifdef _WIN32 +// workaround QTBUG-38598, allow for launching from another directory +static void add_program_library_path() +{ + { + char* p = _pgmptr; + { + char path[MAX_PATH]; + strcpy(path, p); + char* ptr = strrchr(path, '\\'); + if (ptr) + { + printf("%s\n", path); + *ptr = '\0'; + printf("%s\n", path); + QCoreApplication::addLibraryPath(path); + } + } + } +#endif +} int main(int argc, char** argv) { +#ifdef _WIN32 + add_program_library_path(); +#endif // workaround QTBUG-38598 QCoreApplication::addLibraryPath("."); |