Skip to content

Commit 2ba2837

Browse files
committed
Fixed bug where client would crash if hotspot callback deleted its own hotspot
1 parent 9226db0 commit 2ba2837

File tree

1 file changed

+57
-7
lines changed

1 file changed

+57
-7
lines changed

mushview.cpp

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6642,6 +6642,16 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
66426642

66436643
} // previous one which isn't this one, or we are no longer on one
66446644

6645+
if (pHotspot)
6646+
{
6647+
// re-establish hotspot pointer in case previous callback deleted it
6648+
HotspotMapIterator it = mw->m_Hotspots.find (sHotspotId);
6649+
if (it == mw->m_Hotspots.end ())
6650+
pHotspot = NULL;
6651+
else
6652+
pHotspot = it->second;
6653+
} // if had a hotspot before
6654+
66456655
// now, are we now over a hotspot?
66466656
if (pHotspot)
66476657
{
@@ -6672,6 +6682,16 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
66726682
} // end of having tooltip window
66736683

66746684

6685+
if (pHotspot)
6686+
{
6687+
// re-establish hotspot pointer in case previous callback deleted it
6688+
HotspotMapIterator it = mw->m_Hotspots.find (sHotspotId);
6689+
if (it == mw->m_Hotspots.end ())
6690+
pHotspot = NULL;
6691+
else
6692+
pHotspot = it->second;
6693+
} // if had a hotspot before
6694+
66756695
// capture mouse movements out of the miniwindow (version 4.46)
66766696
// see: http://www.gammon.com.au/forum/?id=9980
66776697

@@ -6782,6 +6802,16 @@ bool CMUSHView::Mouse_Down_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long
67826802
{
67836803
mw->m_sMouseOverHotspot.erase ();
67846804

6805+
if (pHotspot)
6806+
{
6807+
// re-establish hotspot pointer in case previous callback deleted it
6808+
HotspotMapIterator it = mw->m_Hotspots.find (sHotspotId);
6809+
if (it == mw->m_Hotspots.end ())
6810+
pHotspot = NULL;
6811+
else
6812+
pHotspot = it->second;
6813+
} // if had a hotspot before
6814+
67856815
// now, are we now over a hotspot?
67866816
if (pHotspot)
67876817
{
@@ -6948,6 +6978,16 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
69486978
ReleaseCapture(); // Release the mouse capture established at
69496979
// the beginning of the mouse click.
69506980

6981+
if (pHotspot)
6982+
{
6983+
// re-establish hotspot pointer in case previous callback deleted it
6984+
HotspotMapIterator it = mw->m_Hotspots.find (sHotspotId);
6985+
if (it == mw->m_Hotspots.end ())
6986+
pHotspot = NULL;
6987+
else
6988+
pHotspot = it->second;
6989+
} // if had a hotspot before
6990+
69516991
// if mouse-up outside the current hotspot just cancel previous one
69526992
// cancel previous mouse-down hotspot (in this miniwindow)
69536993
if ((pHotspot == NULL || // not on any hotspot
@@ -6969,16 +7009,26 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
69697009

69707010
} // previous one which isn't this one, or we are no longer on one
69717011

7012+
if (pHotspot)
7013+
{
7014+
// re-establish hotspot pointer in case previous callback deleted it
7015+
HotspotMapIterator it = mw->m_Hotspots.find (sHotspotId);
7016+
if (it == mw->m_Hotspots.end ())
7017+
pHotspot = NULL;
7018+
else
7019+
pHotspot = it->second;
7020+
} // if had a hotspot before
7021+
69727022
// now, did we release mouse over the hotspot it went down in?
69737023
if (pHotspot && sOldMouseDownHotspotInThisWindow == sHotspotId)
69747024
{
6975-
mw->m_bExecutingScript = true;
6976-
Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseUp,
6977-
mw->m_sCallbackPlugin,
6978-
pHotspot->m_sMouseUp,
6979-
sHotspotId,
6980-
mw->m_FlagsOnMouseDown); // LH / RH mouse?
6981-
mw->m_bExecutingScript = false;
7025+
mw->m_bExecutingScript = true;
7026+
Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseUp,
7027+
mw->m_sCallbackPlugin,
7028+
pHotspot->m_sMouseUp,
7029+
sHotspotId,
7030+
mw->m_FlagsOnMouseDown); // LH / RH mouse?
7031+
mw->m_bExecutingScript = false;
69827032
}
69837033

69847034
m_sPreviousMiniWindow.erase (); // no longer have a previous mouse-over

0 commit comments

Comments
 (0)