From 0f8ab824a356bb8dc9a2233be0cd2af6e3187aa6 Mon Sep 17 00:00:00 2001 From: PB Date: Sun, 2 Jan 2022 17:56:44 +0100 Subject: [PATCH] Fix using const char* and wxString in ternary operator Using a const char* and a wxString in the two branches of the ternary operator resulted in compile-time errors since the result type of the conditional expression was ambiguous, so add explicit conversions to fix it. Closes https://github.com/wxWidgets/wxWidgets/pull/2634 See #19355. --- samples/internat/internat.cpp | 2 +- samples/widgets/dirctrl.cpp | 2 +- src/propgrid/props.cpp | 2 +- tests/testimage.h | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/samples/internat/internat.cpp b/samples/internat/internat.cpp index 15f8319239..2ac48aedce 100644 --- a/samples/internat/internat.cpp +++ b/samples/internat/internat.cpp @@ -210,7 +210,7 @@ bool MyApp::OnInit() langInfo = wxLocale::GetLanguageInfo(wxLANGUAGE_DEFAULT); const wxString langDesc = langInfo ? langInfo->Description - : "the default system locale"; + : wxString("the default system locale"); if ( m_setLocale == Locale_Ask ) { diff --git a/samples/widgets/dirctrl.cpp b/samples/widgets/dirctrl.cpp index 34903e9037..6cd3a3649c 100644 --- a/samples/widgets/dirctrl.cpp +++ b/samples/widgets/dirctrl.cpp @@ -275,7 +275,7 @@ void DirCtrlWidgetsPage::CreateDirCtrl(bool defaultPath) wxGenericDirCtrl *dirCtrl = new wxGenericDirCtrl( this, DirCtrlPage_Ctrl, - defaultPath ? wxDirDialogDefaultFolderStr : m_dirCtrl->GetPath(), + defaultPath ? wxString(wxDirDialogDefaultFolderStr) : m_dirCtrl->GetPath(), wxDefaultPosition, wxDefaultSize, style diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index 01f4100936..1aacc6de2e 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -2199,7 +2199,7 @@ bool wxFileProperty::DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) m_dlgTitle.empty() ? _("Choose a file") : m_dlgTitle, m_initialPath.empty() ? path : m_initialPath, file, - m_wildcard.empty() ? wxALL_FILES : m_wildcard, + m_wildcard.empty() ? _(wxALL_FILES) : m_wildcard, m_dlgStyle, wxDefaultPosition); diff --git a/tests/testimage.h b/tests/testimage.h index f27f61ac37..50f676d7de 100644 --- a/tests/testimage.h +++ b/tests/testimage.h @@ -63,6 +63,7 @@ public: } } + const wxString dispAlphaValNull("--"); const unsigned char* d1 = m_image.GetData(); const unsigned char* d2 = other.GetData(); const unsigned char* a1 = m_image.GetAlpha(); @@ -72,8 +73,8 @@ public: { for ( int x = 0; x < m_image.GetWidth(); ++x ) { - wxString a1txt = dispAlphaVal ? (a1 != NULL ? wxString::Format("%02x", *a1) : "--") : ""; - wxString a2txt = dispAlphaVal ? (a2 != NULL ? wxString::Format("%02x", *a2) : "--") : ""; + wxString a1txt = dispAlphaVal ? (a1 != NULL ? wxString::Format("%02x", *a1) : dispAlphaValNull) : wxString(); + wxString a2txt = dispAlphaVal ? (a2 != NULL ? wxString::Format("%02x", *a2) : dispAlphaValNull) : wxString(); for ( int i = 0; i < 3; i++ ) {