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

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;
SHGetKnownFolderPath(FOLDERID_Programs, 0, NULL, &userShortcutFolder);
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);
CoTaskMemFree(userShortcutFolder);
const auto result = shortcutDialog.ShowModal();
if (result == wxID_CANCEL)
return;
@ -1621,7 +1623,7 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo)
}
icon_path = folder / fmt::format("{:016x}.ico", titleId);
auto stream = wxFileOutputStream(_pathToUtf8(*icon_path));
auto stream = wxFileOutputStream(icon_path->wstring());
auto image = bitmap.ConvertToImage();
wxICOHandler icohandler{};
if (!icohandler.SaveFile(&image, stream, false))