From 3fa764321eb37b62463137e2797c999d1d3fdf7f Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 8 May 2017 22:09:38 +0100 Subject: [PATCH] Fix string errors and warnings --- src/openrct2-ui/UiContext.Linux.cpp | 23 ++++++++++++++----- .../drawing/engines/SoftwareDrawingEngine.cpp | 1 + .../engines/opengl/OpenGLDrawingEngine.cpp | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/openrct2-ui/UiContext.Linux.cpp b/src/openrct2-ui/UiContext.Linux.cpp index 2692a85f8e..95cabdfca9 100644 --- a/src/openrct2-ui/UiContext.Linux.cpp +++ b/src/openrct2-ui/UiContext.Linux.cpp @@ -123,7 +123,12 @@ namespace OpenRCT2 { namespace Ui (desc.Type == FILE_DIALOG_TYPE::OPEN) ? "--getopenfilename" : "--getsavefilename"; std::string filter = GetKDialogFilterString(desc.Filters); - std::string cmd = String::StdFormat("%s --title '%s' %s '%s/' ~ '%s'", executablePath, desc.Title, action, desc.InitialDirectory, filter); + std::string cmd = String::StdFormat("%s --title '%s' %s '%s/' ~ '%s'", + executablePath.c_str(), + desc.Title.c_str(), + action.c_str(), + desc.InitialDirectory.c_str(), + filter.c_str()); std::string output; if (Execute(cmd, &output) != 0) { @@ -140,7 +145,13 @@ namespace OpenRCT2 { namespace Ui flags = "--confirm-overwrite --save"; } std::string filters = GetZenityFilterString(desc.Filters); - std::string cmd = String::StdFormat("%s %s --filename='%s/' %s --title='%s' / %s", executablePath, action, desc.InitialDirectory, flags, desc.Title, filters); + std::string cmd = String::StdFormat("%s %s --filename='%s/' %s --title='%s' / %s", + executablePath.c_str(), + action.c_str(), + desc.InitialDirectory.c_str(), + flags.c_str(), + desc.Title.c_str(), + filters.c_str()); std::string output; if (Execute(cmd, &output) != 0) { @@ -163,7 +174,7 @@ namespace OpenRCT2 { namespace Ui } else if (desc.Type == FILE_DIALOG_TYPE::SAVE && access(result.c_str(), F_OK) != -1 && dtype == DIALOG_TYPE::KDIALOG) { - std::string cmd = String::StdFormat("%s --yesno \"Overwrite %s?\"", executablePath, result.c_str()); + std::string cmd = String::StdFormat("%s --yesno \"Overwrite %s?\"", executablePath.c_str(), result.c_str()); if (Execute(cmd) != 0) { result = std::string(); @@ -181,7 +192,7 @@ namespace OpenRCT2 { namespace Ui case DIALOG_TYPE::KDIALOG: { std::string output; - std::string cmd = String::Format("%s --title '%s' --getexistingdirectory /", executablePath.c_str(), title); + std::string cmd = String::Format("%s --title '%s' --getexistingdirectory /", executablePath.c_str(), title.c_str()); if (Execute(cmd, &output) == 0) { result = output; @@ -191,7 +202,7 @@ namespace OpenRCT2 { namespace Ui case DIALOG_TYPE::ZENITY: { std::string output; - std::string cmd = String::Format("%s --title='%s' --file-selection --directory /", executablePath.c_str(), title); + std::string cmd = String::Format("%s --title='%s' --file-selection --directory /", executablePath.c_str(), title.c_str()); if (Execute(cmd, &output) == 0) { result = output; @@ -243,7 +254,7 @@ namespace OpenRCT2 { namespace Ui // Trim line breaks size_t outputLength = outputBuffer.size(); - for (size_t i = outputBuffer.size() - 1; i >= 0; i--) + for (size_t i = outputLength - 1; i != SIZE_MAX; i--) { if (outputBuffer[i] == '\n') { diff --git a/src/openrct2-ui/drawing/engines/SoftwareDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/SoftwareDrawingEngine.cpp index 95541b089f..3f967475b2 100644 --- a/src/openrct2-ui/drawing/engines/SoftwareDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/SoftwareDrawingEngine.cpp @@ -234,6 +234,7 @@ public: : _uiContext(uiContext), _hardwareDisplay(hardwareDisplay) { + UNUSED(_uiContext); // Will be used in due course to retrieve window information _drawingContext = new SoftwareDrawingContext(this); #ifdef __ENABLE_LIGHTFX__ _lastLightFXenabled = (gConfigGeneral.enable_light_fx != 0); diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp index aec997f5a4..daff9fa039 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -251,6 +251,7 @@ public: OpenGLDrawingEngine(IUiContext * uiContext) : _uiContext(uiContext) { + UNUSED(_uiContext); // Will be used in due course to retrieve window information _drawingContext = new OpenGLDrawingContext(this); }