From df3728933effcb38162e9167bb17c334e807a9b8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 May 2015 06:35:45 +0200 Subject: main: allow launching with different working directory Workaround QTBUG-38598, add program's directory to dynamic modules' path as a first thing. --- facetracknoir/main.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'facetracknoir') 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 +#endif + #include "ui.h" #include "opentrack/options.hpp" using namespace options; @@ -6,9 +10,35 @@ using namespace options; #include #include #include +#include + +#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("."); -- cgit v1.2.3