Skip to content

Commit

Permalink
Fix #273
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Feb 9, 2025
1 parent 61b732c commit aabcedc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 38 deletions.
38 changes: 7 additions & 31 deletions src/MRadWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,19 +835,6 @@ class MRadCtrl : public MWindowBase
return HTTRANSPARENT;
}

// called in WM_NCDESTROY
virtual void PostNcDestroy()
{
if (m_bTopCtrl)
{
MTRACEA("MRadCtrl::PostNcDestroy: %p\n", m_hwnd);
}
MWindowBase::PostNcDestroy();

// delete the MRadCtrl instance
delete this;
}

void DoTest()
{
WCHAR szText[256];
Expand Down Expand Up @@ -877,6 +864,7 @@ class MRadDialog : public MDialogBase
INT m_xDialogBaseUnit; // the X dialog base unit
INT m_yDialogBaseUnit; // the Y dialog base unit
HBRUSH m_hbrBack; // the background brush
std::vector<std::shared_ptr<MRadCtrl>> m_rad_ctrls;

// contructor
MRadDialog() : m_index_visible(FALSE), m_bMovingSizing(FALSE)
Expand Down Expand Up @@ -1383,10 +1371,11 @@ class MRadDialog : public MDialogBase
void DoSubclass(HWND hCtrl, INT nIndex)
{
// make it an MRadCtrl
MRadCtrl *pCtrl = new MRadCtrl();
auto pCtrl = std::make_shared<MRadCtrl>();
pCtrl->SubclassDx(hCtrl);
pCtrl->m_bTopCtrl = (nIndex != -1);
pCtrl->m_nIndex = nIndex;
m_rad_ctrls.push_back(pCtrl);

if (nIndex != -1) // a top control?
{
Expand Down Expand Up @@ -1554,12 +1543,11 @@ class MRadWindow : public MWindowBase
MTitleToBitmap m_title_to_bitmap; // a title-to-bitmap mapping
MTitleToIcon m_title_to_icon; // a title-to-icon mapping
DialogItemClipboard m_clipboard; // a clipboard manager
MOleHost *m_pOleHost;
std::shared_ptr<MOleHost> m_pOleHost;

// constructor
MRadWindow() : m_xDialogBaseUnit(0), m_yDialogBaseUnit(0),
m_hIcon(NULL), m_hIconSm(NULL), m_clipboard(m_dialog_res),
m_pOleHost(NULL)
m_hIcon(NULL), m_hIconSm(NULL), m_clipboard(m_dialog_res)
{
}

Expand Down Expand Up @@ -1774,14 +1762,8 @@ class MRadWindow : public MWindowBase
::DestroyWindow(m_rad_dialog);
}

if (m_pOleHost)
{
delete m_pOleHost;
m_pOleHost = NULL;
}

m_pOleHost = new MOleHost();
DoSetActiveOleHost(m_pOleHost);
m_pOleHost = std::make_shared<MOleHost>();
DoSetActiveOleHost(m_pOleHost.get());

// get the resource data
m_dialog_res.FixupForRad(false);
Expand Down Expand Up @@ -1955,12 +1937,6 @@ class MRadWindow : public MWindowBase
// MRadWindow WM_DESTROY
void OnDestroy(HWND hwnd)
{
if (m_pOleHost)
{
delete m_pOleHost;
m_pOleHost = NULL;
}

// send ID_DESTROYRAD to the owner
HWND hwndOwner = GetWindow(hwnd, GW_OWNER);
DoSendMessage(hwndOwner, WM_COMMAND, ID_DESTROYRAD, 0);
Expand Down
7 changes: 0 additions & 7 deletions src/MRubberBand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ class MRubberBand : public MWindowBase
return m_hwndTarget;
}

// called after WM_NCDESTROY
virtual void PostNcDestroy()
{
MWindowBase::PostNcDestroy();
delete this;
}

// the window procedure of MRubberBand
virtual LRESULT CALLBACK
WindowProcDx(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Expand Down

0 comments on commit aabcedc

Please sign in to comment.