Skip to content
This repository
Browse code

Miniwindow scripts can no longer delete the invoking miniwindow

  • Loading branch information...
commit d6eb9b585189bc7f1e17efa2b76b1da37b2ae7fa 1 parent d11a909
Nick Gammon authored
3  miniwindow.cpp
@@ -27,7 +27,8 @@ CMiniWindow::CMiniWindow () :
27 27 m_last_mouse_update (0),
28 28 m_client_mouseposition (0, 0),
29 29 m_FlagsOnMouseDown (0),
30   - m_ZOrder (0)
  30 + m_ZOrder (0),
  31 + m_bExecutingScript (false)
31 32 {
32 33 dc.CreateCompatibleDC(NULL);
33 34 dc.SetTextAlign (TA_LEFT | TA_TOP);
1  miniwindow.h
@@ -113,6 +113,7 @@ class CMiniWindow
113 113 string m_sMouseDownHotspot; // last hotspot we mouse clicked in
114 114 long m_FlagsOnMouseDown; // which mouse-down we got
115 115 long m_ZOrder; // Z-order. If zero, use name order. Lower is drawn earlier.
  116 + bool m_bExecutingScript; // so windows don't delete themselves
116 117
117 118 string m_sCallbackPlugin; // plugin we are using
118 119
43 mushview.cpp
@@ -6535,11 +6535,15 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
6535 6535
6536 6536 // call MoveCallback for that hotspot, if it exists
6537 6537 if (it != prev_mw->m_Hotspots.end ())
  6538 + {
  6539 + prev_mw->m_bExecutingScript = true;
6538 6540 Send_Mouse_Event_To_Plugin (it->second->m_dispid_MoveCallback,
6539 6541 prev_mw->m_sCallbackPlugin,
6540 6542 it->second->m_sMoveCallback,
6541 6543 prev_mw->m_sMouseDownHotspot,
6542 6544 prev_mw->m_FlagsOnMouseDown);
  6545 + prev_mw->m_bExecutingScript = false;
  6546 + }
6543 6547 return true; // that's all
6544 6548
6545 6549 } // we had previous hotspot
@@ -6578,10 +6582,12 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
6578 6582 if (it != old_mw->m_Hotspots.end ())
6579 6583 {
6580 6584 RemoveToolTip ();
  6585 + old_mw->m_bExecutingScript = true;
6581 6586 Send_Mouse_Event_To_Plugin (it->second->m_dispid_CancelMouseOver,
6582 6587 old_mw->m_sCallbackPlugin,
6583 6588 it->second->m_sCancelMouseOver,
6584 6589 old_mw->m_sMouseOverHotspot);
  6590 + old_mw->m_bExecutingScript = false;
6585 6591 }
6586 6592 old_mw->m_sMouseOverHotspot.erase (); // no mouse-over right now
6587 6593 m_sPreviousMiniWindow.erase (); // no longer have a previous mouse-over
@@ -6608,10 +6614,12 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
6608 6614 if (it != mw->m_Hotspots.end ())
6609 6615 {
6610 6616 RemoveToolTip ();
  6617 + mw->m_bExecutingScript = true;
6611 6618 Send_Mouse_Event_To_Plugin (it->second->m_dispid_CancelMouseOver,
6612 6619 mw->m_sCallbackPlugin,
6613 6620 it->second->m_sCancelMouseOver,
6614 6621 mw->m_sMouseOverHotspot);
  6622 + mw->m_bExecutingScript = false;
6615 6623 }
6616 6624
6617 6625 mw->m_sMouseOverHotspot.erase (); // no mouse-over right now
@@ -6632,10 +6640,12 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
6632 6640 {
6633 6641 // this is our new one
6634 6642 mw->m_sMouseOverHotspot = sHotspotId;
  6643 + mw->m_bExecutingScript = true;
6635 6644 Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseOver,
6636 6645 mw->m_sCallbackPlugin,
6637 6646 pHotspot->m_sMouseOver,
6638 6647 sHotspotId);
  6648 + mw->m_bExecutingScript = false;
6639 6649 // activate tooltip if possible
6640 6650 if (::IsWindow(m_ToolTip.m_hWnd))
6641 6651 {
@@ -6666,10 +6676,15 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
6666 6676 { // same hotspot (new in version 4.45)
6667 6677 // see lengthy forum discussion: http://www.gammon.com.au/forum/?id=9942
6668 6678 if (pHotspot->m_Flags & 1)
  6679 + {
  6680 + mw->m_bExecutingScript = true;
6669 6681 Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseOver,
6670 6682 mw->m_sCallbackPlugin,
6671 6683 pHotspot->m_sMouseOver,
6672 6684 sHotspotId, 0x80);
  6685 + mw->m_bExecutingScript = false;
  6686 + }
  6687 +
6673 6688 }
6674 6689 }
6675 6690
@@ -6710,10 +6725,14 @@ bool CMUSHView::Mouse_Down_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long
6710 6725
6711 6726 // call CancelMouseOver for that hotspot, if it exists
6712 6727 if (it != old_mw->m_Hotspots.end ())
  6728 + {
  6729 + old_mw->m_bExecutingScript = true;
6713 6730 Send_Mouse_Event_To_Plugin (it->second->m_dispid_CancelMouseOver,
6714 6731 old_mw->m_sCallbackPlugin,
6715 6732 it->second->m_sCancelMouseOver,
6716   - old_mw->m_sMouseOverHotspot);
  6733 + old_mw->m_sMouseOverHotspot);
  6734 + old_mw->m_bExecutingScript = false;
  6735 + }
6717 6736 old_mw->m_sMouseOverHotspot.erase (); // no mouse-over right now
6718 6737 m_sPreviousMiniWindow.erase (); // no longer have a previous mouse-over
6719 6738 } // we had previous hotspot
@@ -6734,12 +6753,13 @@ bool CMUSHView::Mouse_Down_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long
6734 6753 {
6735 6754 mw->m_sMouseDownHotspot = sHotspotId; // remember this is mousedown hotspot
6736 6755 mw->m_FlagsOnMouseDown = flags & 0x70; // remember mouse flags
6737   -
  6756 + mw->m_bExecutingScript = true;
6738 6757 Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseDown,
6739 6758 mw->m_sCallbackPlugin,
6740 6759 pHotspot->m_sMouseDown,
6741 6760 sHotspotId,
6742 6761 flags); // LH / RH mouse?
  6762 + mw->m_bExecutingScript = false;
6743 6763 }
6744 6764
6745 6765 m_sPreviousMiniWindow = sMiniWindowId; // remember in case they move outside window
@@ -6789,11 +6809,15 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
6789 6809
6790 6810 // call ReleaseCallback for that hotspot, if it exists
6791 6811 if (it != prev_mw->m_Hotspots.end ())
  6812 + {
  6813 + prev_mw->m_bExecutingScript = true;
6792 6814 Send_Mouse_Event_To_Plugin (it->second->m_dispid_ReleaseCallback,
6793 6815 prev_mw->m_sCallbackPlugin,
6794 6816 it->second->m_sReleaseCallback,
6795 6817 prev_mw->m_sMouseDownHotspot,
6796 6818 prev_mw->m_FlagsOnMouseDown);
  6819 + prev_mw->m_bExecutingScript = false;
  6820 + }
6797 6821
6798 6822 } // we had previous hotspot
6799 6823
@@ -6834,11 +6858,15 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
6834 6858
6835 6859 // call CancelMouseDown for that hotspot, if it exists
6836 6860 if (it != old_mw->m_Hotspots.end ())
  6861 + {
  6862 + old_mw->m_bExecutingScript = true;
6837 6863 Send_Mouse_Event_To_Plugin (it->second->m_dispid_CancelMouseDown,
6838 6864 old_mw->m_sCallbackPlugin,
6839 6865 it->second->m_sCancelMouseDown,
6840 6866 old_mw->m_sMouseDownHotspot,
6841 6867 old_mw->m_FlagsOnMouseDown);
  6868 + old_mw->m_bExecutingScript = false;
  6869 + }
6842 6870 old_mw->m_sMouseDownHotspot.erase (); // no mouse-down right now
6843 6871 } // we had previous hotspot
6844 6872
@@ -6868,11 +6896,15 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
6868 6896 HotspotMapIterator it = mw->m_Hotspots.find (mw->m_sMouseDownHotspot);
6869 6897
6870 6898 if (it != mw->m_Hotspots.end ())
  6899 + {
  6900 + mw->m_bExecutingScript = true;
6871 6901 Send_Mouse_Event_To_Plugin (it->second->m_dispid_CancelMouseDown,
6872 6902 mw->m_sCallbackPlugin,
6873 6903 it->second->m_sCancelMouseDown,
6874 6904 mw->m_sMouseDownHotspot,
6875 6905 mw->m_FlagsOnMouseDown);
  6906 + mw->m_bExecutingScript = false;
  6907 + }
6876 6908
6877 6909 mw->m_sMouseDownHotspot.erase (); // no mouse-down right now
6878 6910 } // previous one which isn't this one, or we are no longer on one
@@ -6880,12 +6912,13 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
6880 6912 // now, did we release mouse over the hotspot it went down in?
6881 6913 if (pHotspot && mw->m_sMouseDownHotspot == sHotspotId)
6882 6914 {
  6915 + mw->m_bExecutingScript = true;
6883 6916 Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseUp,
6884 6917 mw->m_sCallbackPlugin,
6885 6918 pHotspot->m_sMouseUp,
6886 6919 sHotspotId,
6887 6920 mw->m_FlagsOnMouseDown); // LH / RH mouse?
6888   -
  6921 + mw->m_bExecutingScript = false;
6889 6922 mw->m_sMouseDownHotspot.erase (); // no mouse-down right now
6890 6923 }
6891 6924
@@ -7342,11 +7375,15 @@ bool CMUSHView::Mouse_Wheel_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long
7342 7375
7343 7376 // now, are we now over a hotspot?
7344 7377 if (pHotspot)
  7378 + {
  7379 + mw->m_bExecutingScript = true;
7345 7380 Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_ScrollwheelCallback,
7346 7381 mw->m_sCallbackPlugin,
7347 7382 pHotspot->m_sScrollwheelCallback,
7348 7383 sHotspotId,
7349 7384 delta);
  7385 + mw->m_bExecutingScript = false;
  7386 + }
7350 7387
7351 7388 return true; // we are over mini-window - don't scroll underlying text
7352 7389
3  scripting/methods/methods_miniwindows.cpp
@@ -1267,6 +1267,9 @@ long CMUSHclientDoc::WindowDelete(LPCTSTR Name)
1267 1267 if (it == m_MiniWindows.end ())
1268 1268 return eNoSuchWindow;
1269 1269
  1270 + if (it->second->m_bExecutingScript)
  1271 + return eItemInUse;
  1272 +
1270 1273 delete it->second;
1271 1274
1272 1275 m_MiniWindows.erase (it);

0 comments on commit d6eb9b5

Please sign in to comment.
Something went wrong with that request. Please try again.