debugger: use cross-platform wxWidgets clipboard copy

This was the only place where we used the win32 clipboard API directly.
This commit is contained in:
Crementif 2026-05-16 14:20:32 +02:00
parent 1263e20bae
commit 4013302f6f
2 changed files with 9 additions and 27 deletions

View File

@ -14,6 +14,8 @@
#include "Cemu/ExpressionParser/ExpressionParser.h"
#include "Cafe/HW/Espresso/Debugger/DebugSymbolStorage.h"
#include <wx/clipbrd.h>
wxDEFINE_EVENT(wxEVT_DISASMCTRL_NOTIFY_GOTO_ADDRESS, wxCommandEvent);
#define MAX_SYMBOL_LEN (120)
@ -699,20 +701,11 @@ void DisasmCtrl::OnMouseDClick(const wxPoint& position, uint32 line)
void DisasmCtrl::CopyToClipboard(std::string text)
{
#if BOOST_OS_WINDOWS
if (OpenClipboard(nullptr))
if (wxClipboard::Get()->Open())
{
EmptyClipboard();
const HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, text.size() + 1);
if (hGlobal)
{
memcpy(GlobalLock(hGlobal), text.c_str(), text.size() + 1);
GlobalUnlock(hGlobal);
SetClipboardData(CF_TEXT, hGlobal);
}
CloseClipboard();
wxClipboard::Get()->SetData(new wxTextDataObject(text));
wxClipboard::Get()->Close();
}
#endif
}
static uint32 GetUnrelocatedAddress(MPTR address)

View File

@ -2,6 +2,7 @@
#include "Cafe/OS/RPL/rpl_symbol_storage.h"
#include "Cafe/HW/Espresso/Debugger/Debugger.h"
#include <wx/listctrl.h>
#include <wx/clipbrd.h>
enum ItemColumns
{
@ -100,23 +101,11 @@ void SymbolListCtrl::OnRightClick(wxListEvent& event)
long selected = GetFirstSelected();
if (selected == wxNOT_FOUND || selected >= static_cast<long>(m_visible_items.size()))
return;
auto text = wxString::Format("0x%08x", m_visible_items[selected]->first);
#if BOOST_OS_WINDOWS
if (OpenClipboard(nullptr))
if (wxClipboard::Get()->Open())
{
EmptyClipboard();
const HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, text.size()+1);
if (hGlobal)
{
memcpy(GlobalLock(hGlobal), text.c_str(), text.size() + 1);
GlobalUnlock(hGlobal);
SetClipboardData(CF_TEXT, hGlobal);
GlobalFree(hGlobal);
}
CloseClipboard();
wxClipboard::Get()->SetData(new wxTextDataObject(wxString::Format("0x%08x", m_visible_items[selected]->first)));
wxClipboard::Get()->Close();
}
#endif
}
void SymbolListCtrl::RebuildVisibleItems()