From 2061af6ad4af8416b8f11c2b2fd1802dade0e3e9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 5 Jul 2013 00:20:47 +0200 Subject: Deal correctly with non-latin1 characters in directory name --- facetracknoir/facetracknoir.cpp | 9 +++------ facetracknoir/global-settings.cpp | 4 ++-- facetracknoir/global-settings.h | 2 +- facetracknoir/main.cpp | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index aa072401..bb0cef11 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -1022,8 +1022,7 @@ void FaceTrackNoIR::createIconGroupBox() QIcon icon; QString longName; QString str = protocols.at(i); - QByteArray latin1 = str.toLatin1(); - DynamicLibrary* lib = new DynamicLibrary(latin1.constData()); + DynamicLibrary* lib = new DynamicLibrary(str); qDebug() << "Loading" << str; std::cout.flush(); Metadata* meta; @@ -1047,8 +1046,7 @@ void FaceTrackNoIR::createIconGroupBox() QIcon icon; QString longName; QString str = trackers.at(i); - QByteArray latin1 = str.toLatin1(); - DynamicLibrary* lib = new DynamicLibrary(latin1.constData()); + DynamicLibrary* lib = new DynamicLibrary(str); qDebug() << "Loading" << str; std::cout.flush(); Metadata* meta; @@ -1074,8 +1072,7 @@ void FaceTrackNoIR::createIconGroupBox() QIcon icon; QString fullName; QString str = filters.at(i); - QByteArray latin1 = str.toLatin1(); - DynamicLibrary* lib = new DynamicLibrary(latin1.constData()); + DynamicLibrary* lib = new DynamicLibrary(str); qDebug() << "Loading" << str; std::cout.flush(); Metadata* meta; diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index 2ab08a9d..f605b591 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -88,7 +88,7 @@ SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : correct = true; } -DynamicLibrary::DynamicLibrary(const char* filename) +DynamicLibrary::DynamicLibrary(const QString& filename) { this->filename = filename; QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; @@ -98,7 +98,7 @@ DynamicLibrary::DynamicLibrary(const char* filename) Constructor = (NULLARY_DYNAMIC_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); Metadata = (METADATA_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetMetadata" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); #else - QByteArray latin1 = fullPath.toLatin1(); + QByteArray latin1 = QFile::encodeName(filename); handle = dlopen(latin1.constData(), RTLD_NOW | # ifdef __linux RTLD_DEEPBIND diff --git a/facetracknoir/global-settings.h b/facetracknoir/global-settings.h index 62f00831..29a8da62 100644 --- a/facetracknoir/global-settings.h +++ b/facetracknoir/global-settings.h @@ -50,7 +50,7 @@ extern "C" typedef void* (CALLING_CONVENTION* SETTINGS_FUNCTION)(void); class DynamicLibrary { public: - DynamicLibrary(const char* filename); + DynamicLibrary(const QString& filename); virtual ~DynamicLibrary(); SETTINGS_FUNCTION Dialog; NULLARY_DYNAMIC_FUNCTION Constructor; diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 8ba437bf..fd0ca1cc 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -36,7 +36,7 @@ #if defined(_WIN32) #include -//#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup") +//#pragma comment(linker, "/SUBSYSTEM:console /ENTRY:mainCRTStartup") #endif int main(int argc, char** argv) { -- cgit v1.2.3