Prepare for changes in wxWidgets 3.3 (#1343)

* Move from deprecated wxScopedPtr to std::unique_ptr
wxScopedPtr was included previously through some header hierarchy which as of 3.3 is
no longer the case causing it to break. But instead of including a header for a deprecated
function explicitly, just move to std::unique_ptr as recommended by upstream.

* Convert to explicit conversions from wxString
As of 35c35c235e
wxWidgets defaults to STL classes, which has a side-effect that
some implicit conversions break. This patch converts those conversions
to explicit in anticipation of wxWidgets 3.3 release.
This commit is contained in:
Jertzukka 2024-05-18 04:46:39 +03:00 committed by GitHub
parent 55c3a8dc58
commit 114624b3a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 7 additions and 7 deletions

View File

@ -89,7 +89,7 @@ namespace VeraCrypt
FilePath Application::GetConfigFilePath (const wxString &configFileName, bool createConfigDir) FilePath Application::GetConfigFilePath (const wxString &configFileName, bool createConfigDir)
{ {
static wxScopedPtr<const wxString> configDirC; static std::unique_ptr<const wxString> configDirC;
static bool configDirExists = false; static bool configDirExists = false;
if (!configDirExists) if (!configDirExists)

View File

@ -975,7 +975,7 @@ namespace VeraCrypt
if (OuterVolume && VolumeSize > TC_MAX_FAT_SECTOR_COUNT * SectorSize) if (OuterVolume && VolumeSize > TC_MAX_FAT_SECTOR_COUNT * SectorSize)
{ {
uint64 limit = TC_MAX_FAT_SECTOR_COUNT * SectorSize / BYTES_PER_TB; uint64 limit = TC_MAX_FAT_SECTOR_COUNT * SectorSize / BYTES_PER_TB;
wstring err = StringFormatter (LangString["LINUX_ERROR_SIZE_HIDDEN_VOL"], limit, limit * 1024); wstring err = static_cast<wstring>(StringFormatter (LangString["LINUX_ERROR_SIZE_HIDDEN_VOL"], limit, limit * 1024));
if (SectorSize < 4096) if (SectorSize < 4096)
{ {

View File

@ -71,12 +71,12 @@ namespace VeraCrypt
UserPreferences Preferences; UserPreferences Preferences;
Preferences.Load(); Preferences.Load();
wstring preferredLang = Preferences.Language; string preferredLang = string(Preferences.Language.begin(), Preferences.Language.end());
#ifdef DEBUG #ifdef DEBUG
std::cout << "Config language: " << preferredLang << std::endl; std::cout << "Config language: " << preferredLang << std::endl;
#endif #endif
if (preferredLang == L"system") { if (preferredLang == "system") {
if (const char *env_p = getenv("LANG")) { if (const char *env_p = getenv("LANG")) {
string lang(env_p); string lang(env_p);
#ifdef DEBUG #ifdef DEBUG

View File

@ -52,7 +52,7 @@ namespace VeraCrypt
StringFormatter (const wxString &format, StringFormatterArg arg0 = StringFormatterArg(), StringFormatterArg arg1 = StringFormatterArg(), StringFormatterArg arg2 = StringFormatterArg(), StringFormatterArg arg3 = StringFormatterArg(), StringFormatterArg arg4 = StringFormatterArg(), StringFormatterArg arg5 = StringFormatterArg(), StringFormatterArg arg6 = StringFormatterArg(), StringFormatterArg arg7 = StringFormatterArg(), StringFormatterArg arg8 = StringFormatterArg(), StringFormatterArg arg9 = StringFormatterArg()); StringFormatter (const wxString &format, StringFormatterArg arg0 = StringFormatterArg(), StringFormatterArg arg1 = StringFormatterArg(), StringFormatterArg arg2 = StringFormatterArg(), StringFormatterArg arg3 = StringFormatterArg(), StringFormatterArg arg4 = StringFormatterArg(), StringFormatterArg arg5 = StringFormatterArg(), StringFormatterArg arg6 = StringFormatterArg(), StringFormatterArg arg7 = StringFormatterArg(), StringFormatterArg arg8 = StringFormatterArg(), StringFormatterArg arg9 = StringFormatterArg());
virtual ~StringFormatter (); virtual ~StringFormatter ();
operator wstring () const { return wstring (FormattedString); } explicit operator wstring () const { return wstring (FormattedString); }
operator wxString () const { return FormattedString; } operator wxString () const { return FormattedString; }
operator StringFormatterArg () const { return FormattedString; } operator StringFormatterArg () const { return FormattedString; }

View File

@ -390,7 +390,7 @@ namespace VeraCrypt
errOutput += StringConverter::ToWide (execEx->GetErrorOutput()); errOutput += StringConverter::ToWide (execEx->GetErrorOutput());
if (errOutput.empty()) if (errOutput.empty())
return errOutput + StringFormatter (LangString["LINUX_COMMAND_GET_ERROR"], execEx->GetCommand(), execEx->GetExitCode()); return errOutput + static_cast<wstring>(StringFormatter (LangString["LINUX_COMMAND_GET_ERROR"], execEx->GetCommand(), execEx->GetExitCode()));
return wxString (errOutput).Trim (true); return wxString (errOutput).Trim (true);
} }
@ -1516,7 +1516,7 @@ namespace VeraCrypt
EncryptionTest::TestAll(); EncryptionTest::TestAll();
// StringFormatter // StringFormatter
if (StringFormatter (L"{9} {8} {7} {6} {5} {4} {3} {2} {1} {0} {{0}}", "1", L"2", '3', L'4', 5, 6, 7, 8, 9, 10) != L"10 9 8 7 6 5 4 3 2 1 {0}") if (static_cast<wstring>(StringFormatter (L"{9} {8} {7} {6} {5} {4} {3} {2} {1} {0} {{0}}", "1", L"2", '3', L'4', 5, 6, 7, 8, 9, 10)) != L"10 9 8 7 6 5 4 3 2 1 {0}")
throw TestFailed (SRC_POS); throw TestFailed (SRC_POS);
try try
{ {