From 4013302f6f179f80d97f8323151a9d1aafa948a4 Mon Sep 17 00:00:00 2001 From: Crementif <26669564+Crementif@users.noreply.github.com> Date: Sat, 16 May 2026 14:20:32 +0200 Subject: [PATCH] debugger: use cross-platform wxWidgets clipboard copy This was the only place where we used the win32 clipboard API directly. --- src/gui/wxgui/debugger/DisasmCtrl.cpp | 17 +++++------------ src/gui/wxgui/debugger/SymbolCtrl.cpp | 19 ++++--------------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/gui/wxgui/debugger/DisasmCtrl.cpp b/src/gui/wxgui/debugger/DisasmCtrl.cpp index 33da4774..913df026 100644 --- a/src/gui/wxgui/debugger/DisasmCtrl.cpp +++ b/src/gui/wxgui/debugger/DisasmCtrl.cpp @@ -14,6 +14,8 @@ #include "Cemu/ExpressionParser/ExpressionParser.h" #include "Cafe/HW/Espresso/Debugger/DebugSymbolStorage.h" +#include + 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) diff --git a/src/gui/wxgui/debugger/SymbolCtrl.cpp b/src/gui/wxgui/debugger/SymbolCtrl.cpp index 533b259e..8675259c 100644 --- a/src/gui/wxgui/debugger/SymbolCtrl.cpp +++ b/src/gui/wxgui/debugger/SymbolCtrl.cpp @@ -2,6 +2,7 @@ #include "Cafe/OS/RPL/rpl_symbol_storage.h" #include "Cafe/HW/Espresso/Debugger/Debugger.h" #include +#include enum ItemColumns { @@ -100,23 +101,11 @@ void SymbolListCtrl::OnRightClick(wxListEvent& event) long selected = GetFirstSelected(); if (selected == wxNOT_FOUND || selected >= static_cast(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()