Fix path text encoding creating shortcuts on windows
Some checks failed
Generate translation template / generate-pot (push) Failing after 57s
Build check / build (push) Has been cancelled

also fix a memory leak
(hopefully)
fixes: #1627
This commit is contained in:
goeiecool9999 2025-07-02 12:41:04 +02:00
parent 35ecfa3f54
commit e68c31e5fb

View file

@ -1589,9 +1589,11 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo)
PWSTR userShortcutFolder; PWSTR userShortcutFolder;
SHGetKnownFolderPath(FOLDERID_Programs, 0, NULL, &userShortcutFolder); SHGetKnownFolderPath(FOLDERID_Programs, 0, NULL, &userShortcutFolder);
const wxString shortcutName = wxString::Format("%s.lnk", titleName); const wxString shortcutName = wxString::Format("%s.lnk", titleName);
wxFileDialog shortcutDialog(this, _("Choose shortcut location"), _pathToUtf8(userShortcutFolder), shortcutName, wxFileDialog shortcutDialog(this, _("Choose shortcut location"), userShortcutFolder, shortcutName,
"Shortcut (*.lnk)|*.lnk", wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT); "Shortcut (*.lnk)|*.lnk", wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT);
CoTaskMemFree(userShortcutFolder);
const auto result = shortcutDialog.ShowModal(); const auto result = shortcutDialog.ShowModal();
if (result == wxID_CANCEL) if (result == wxID_CANCEL)
return; return;
@ -1621,7 +1623,7 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo)
} }
icon_path = folder / fmt::format("{:016x}.ico", titleId); icon_path = folder / fmt::format("{:016x}.ico", titleId);
auto stream = wxFileOutputStream(_pathToUtf8(*icon_path)); auto stream = wxFileOutputStream(icon_path->wstring());
auto image = bitmap.ConvertToImage(); auto image = bitmap.ConvertToImage();
wxICOHandler icohandler{}; wxICOHandler icohandler{};
if (!icohandler.SaveFile(&image, stream, false)) if (!icohandler.SaveFile(&image, stream, false))