Fix narrow/wide string concatenation errors for wxWidgets 3.3

In wx 3.3 with wxUSE_STD_CONTAINERS=ON, wxString is backed by
std::wstring, so direct concatenation of const char[] with
std::wstring or wxUniCharRef fails. Fix by splitting compound
concatenations into separate += operations on wxString, or by
wrapping the left operand in wxString() to use its operator+.

Files fixed:
- AuxiliaryDataViewModel.cpp: split "\\" + wxString/wstring chains
- AboutDialog.cpp: split std::string("\n") + wxUniCharRef
- Auxiliary.cpp: wrap dir.wstring() in wxString(), split "/" + wstring
This commit is contained in:
SoftFever
2026-03-25 11:28:00 +08:00
parent 5f365b5c6b
commit d9c229ca35
3 changed files with 12 additions and 7 deletions

View File

@@ -293,7 +293,8 @@ AboutDialog::AboutDialog()
find_txt += text_list[i][o];
count_txt += text_list[i][o];
} else {
find_txt += std::string("\n") + text_list[i][o];
find_txt += "\n";
find_txt += text_list[i][o];
count_txt = text_list[i][o];
}
}

View File

@@ -368,7 +368,7 @@ void AuFile::on_input_enter(wxCommandEvent &evt)
auto new_fullname = new_file_name + m_file_path.extension().string();
wxString new_fullname_path = dir.wstring() + "/" + new_fullname;
wxString new_fullname_path = wxString(dir.wstring()) + "/" + new_fullname;
fs::path new_dir_path(new_fullname_path.ToStdWstring());
@@ -955,7 +955,8 @@ void AuxiliaryPanel::on_import_file(wxCommandEvent &event)
}
if (!is_exist) {
dir_path += "/" + src_bfs_path.filename().generic_wstring();
dir_path += "/";
dir_path += src_bfs_path.filename().generic_wstring();
} else {
time_t t1 = time(0);
char ch1[64];
@@ -965,7 +966,7 @@ void AuxiliaryPanel::on_import_file(wxCommandEvent &event)
wxString name = src_bfs_path.filename().generic_wstring();
auto before_name = replaceSpace(name.ToStdString(), src_bfs_path.extension().string(), "");
time_text = replaceSpace(time_text, ":", "_");
dir_path += "/" + before_name + "_" + time_text + src_bfs_path.extension().wstring();
dir_path += wxString("/") + before_name + "_" + time_text + src_bfs_path.extension().wstring();
}

View File

@@ -332,9 +332,12 @@ wxDataViewItemArray AuxiliaryModel::ImportFile(AuxiliaryModelNode* sel, wxArrayS
// Copy imported file to project temp directory
fs::path src_bfs_path(file_path.ToStdWstring());
wxString dir_path = m_root_dir;
if (sel != m_root)
dir_path += "\\" + sel->name;
dir_path += "\\" + src_bfs_path.filename().generic_wstring();
if (sel != m_root) {
dir_path += "\\";
dir_path += sel->name;
}
dir_path += "\\";
dir_path += src_bfs_path.filename().generic_wstring();
boost::system::error_code ec;
if (!fs::copy_file(src_bfs_path, fs::path(dir_path.ToStdWstring()), fs::copy_options::overwrite_existing, ec))