Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing of non-ASCII characters as command-line arguments #127

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Base/Testing/Cpp/ctkAppLauncherEnvironmentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@ void ctkAppLauncherEnvironmentTester::cleanup()
QStringList originalEnvKeys = ctkAppLauncherEnvironment::envKeys(this->OriginalEnv);
foreach(const QString& varName, originalEnvKeys)
{
qputenv(varName.toLatin1(), this->OriginalEnv.value(varName).toLatin1());
qputenv(varName.toLocal8Bit(), this->OriginalEnv.value(varName).toLocal8Bit());
}
}

// ----------------------------------------------------------------------------
void ctkAppLauncherEnvironmentTester::setEnv(const QString& name, const QString& value)
{
qputenv(name.toLatin1(), value.toLatin1());
qputenv(name.toLocal8Bit(), value.toLocal8Bit());
this->VariableNames.insert(name);
}

// ----------------------------------------------------------------------------
void ctkAppLauncherEnvironmentTester::unsetEnv(const QString& name)
{
#if defined(_MSC_VER)
qputenv(name.toLatin1(), QString("").toLatin1());
qputenv(name.toLocal8Bit(), QString().toLocal8Bit());
#else
unsetenv(name.toLatin1());
unsetenv(name.toLocal8Bit());
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion Base/ctkAppArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void ctkChar2DArray::setValues(const QStringList& list)
{
QString item = d->List.at(index);
d->Values[index] = new char[item.size() + 1];
qstrcpy(d->Values[index], item.toLatin1().data());
qstrcpy(d->Values[index], item.toLocal8Bit().data());
}
}

Expand Down
6 changes: 3 additions & 3 deletions Base/ctkAppLauncherEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ void ctkAppLauncherEnvironment::updateCurrentEnvironment(const QProcessEnvironme
foreach(const QString& varName, variablesToUnset)
{
#if defined(Q_OS_WIN32)
bool success = qputenv(varName.toLatin1(), QString("").toLatin1());
bool success = qputenv(varName.toLocal8Bit(), QString().toLocal8Bit());
#else
bool success = unsetenv(varName.toLatin1()) == EXIT_SUCCESS;
bool success = unsetenv(varName.toLocal8Bit()) == EXIT_SUCCESS;
#endif
if (!success)
{
Expand All @@ -180,7 +180,7 @@ void ctkAppLauncherEnvironment::updateCurrentEnvironment(const QProcessEnvironme
foreach(const QString& varName, envKeys)
{
QString varValue = environment.value(varName);
bool success = qputenv(varName.toLatin1(), varValue.toLatin1());
bool success = qputenv(varName.toLocal8Bit(), varValue.toLocal8Bit());
if (!success)
{
qWarning() << "Failed to set environment variable"
Expand Down
4 changes: 2 additions & 2 deletions Base/ctkTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ static void mouseEvent(QTest::MouseAction action, QWidget *widget, Qt::MouseButt
{
static const char *mouseActionNames[] =
{ "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" };
QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget");
QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toLatin1());
QString warning = QLatin1String("Mouse event \"%1\" not accepted by receiving widget");
QTest::qWarn(warning.arg(QLatin1String(mouseActionNames[static_cast<int>(action)])).toLocal8Bit());
}
}

Expand Down
4 changes: 4 additions & 0 deletions msvc-static-configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ elseif ("$ENV{APPLAUNCHER_CMAKE_GENERATOR}" STREQUAL "Visual Studio 16 2019")
# For local build with Visual Studio 2019 with modern CMake
set(APPLAUNCHER_CMAKE_GENERATOR -G "Visual Studio 16 2019" -T v141 -A Win32)
set(APPLAUNCHER_USE_NINJA OFF)
elseif ("$ENV{APPLAUNCHER_CMAKE_GENERATOR}" STREQUAL "Visual Studio 17 2022")
# For local build with Visual Studio 2019 with modern CMake
set(APPLAUNCHER_CMAKE_GENERATOR -G "Visual Studio 17 2022" -T v143 -A Win32)
set(APPLAUNCHER_USE_NINJA OFF)
else()
message(FATAL_ERROR "Env. variable APPLAUNCHER_CMAKE_GENERATOR is expected to match 'Ninja' or 'Visual Studio 15 2017' or 'Visual Studio 16 2019' [$ENV{APPLAUNCHER_CMAKE_GENERATOR}]")
endif()
Expand Down
Loading