Skip to content

Commit 52eda2d

Browse files
Turn MCmousestackptr into an object handle
1 parent d6e3582 commit 52eda2d

File tree

11 files changed

+33
-31
lines changed

11 files changed

+33
-31
lines changed

engine/src/button.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2705,7 +2705,7 @@ bool MCSystemPick(MCStringRef p_options, bool p_use_checkmark, uint32_t p_initia
27052705

27062706
void MCButton::openmenu(Boolean grab)
27072707
{
2708-
if (!opened || MCmousestackptr == NULL)
2708+
if (!opened || !MCmousestackptr)
27092709
return;
27102710
if (!MCNameIsEmpty(menuname) && !MCModeMakeLocalWindows())
27112711
return;

engine/src/card.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3455,8 +3455,8 @@ Exec_stat MCCard::closecontrols(void)
34553455
// is a property of the mouseControl. Will return NULL if no mouseControl exists.
34563456
MCControl *MCCard::getmousecontrol(void)
34573457
{
3458-
if (MCmousestackptr == NULL)
3459-
return NULL;
3458+
if (!MCmousestackptr)
3459+
return nil;
34603460

34613461
MCControl *t_focused;
34623462
t_focused = MCmousestackptr -> getcard() -> getmfocused();

engine/src/dispatch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ void MCDispatch::wmdragenter(Window w)
14741474
MCdragboard->PullUpdates();
14751475

14761476
// Change the mouse focus to the stack that has had the drag enter it
1477-
if (MCmousestackptr != NULL && target != MCmousestackptr)
1477+
if (MCmousestackptr && target != MCmousestackptr)
14781478
MCmousestackptr -> munfocus();
14791479

14801480
MCmousestackptr = target;
@@ -1511,7 +1511,7 @@ void MCDispatch::wmdragleave(Window w)
15111511
if (target != NULL && target == MCmousestackptr)
15121512
{
15131513
MCmousestackptr -> munfocus();
1514-
MCmousestackptr = NULL;
1514+
MCmousestackptr = nil;
15151515
}
15161516

15171517
// We are no longer the drop target and no longer care about the drag data.
@@ -1532,7 +1532,7 @@ MCDragAction MCDispatch::wmdragdrop(Window w)
15321532
dodrop(false);
15331533

15341534
// The drag operation has ended. Remove the drag board contents.
1535-
MCmousestackptr = NULL;
1535+
MCmousestackptr = nil;
15361536
MCdragboard->Clear();
15371537
m_drag_target = false;
15381538

engine/src/exec-interface.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ void MCInterfaceEvalMouseLoc(MCExecContext& ctxt, MCStringRef& r_string)
709709

710710
void MCInterfaceEvalMouseChar(MCExecContext& ctxt, MCStringRef& r_string)
711711
{
712-
if (MCmousestackptr != nil)
712+
if (MCmousestackptr)
713713
{
714714
MCControl *mfocused = MCmousestackptr->getcard()->getmfocused();
715715
if (mfocused != NULL && mfocused->gettype() == CT_FIELD)
@@ -728,7 +728,7 @@ void MCInterfaceEvalMouseChar(MCExecContext& ctxt, MCStringRef& r_string)
728728

729729
void MCInterfaceEvalMouseText(MCExecContext& ctxt, MCStringRef& r_string)
730730
{
731-
if (MCmousestackptr != nil)
731+
if (MCmousestackptr)
732732
{
733733
MCControl *mfocused = MCmousestackptr->getcard()->getmfocused();
734734
if (mfocused != NULL && mfocused->gettype() == CT_FIELD)
@@ -749,7 +749,7 @@ void MCInterfaceEvalMouseText(MCExecContext& ctxt, MCStringRef& r_string)
749749

750750
void MCInterfaceEvalMouseCharChunk(MCExecContext& ctxt, MCStringRef& r_string)
751751
{
752-
if (MCmousestackptr != nil)
752+
if (MCmousestackptr)
753753
{
754754
MCControl *mfocused = MCmousestackptr->getcard()->getmfocused();
755755
if (mfocused != NULL && mfocused->gettype() == CT_FIELD)
@@ -770,7 +770,7 @@ void MCInterfaceEvalMouseCharChunk(MCExecContext& ctxt, MCStringRef& r_string)
770770

771771
void MCInterfaceEvalMouseChunk(MCExecContext& ctxt, MCStringRef& r_string)
772772
{
773-
if (MCmousestackptr != nil)
773+
if (MCmousestackptr)
774774
{
775775
MCControl *mfocused = MCmousestackptr->getcard()->getmfocused();
776776
if (mfocused != NULL && mfocused->gettype() == CT_FIELD)
@@ -791,7 +791,7 @@ void MCInterfaceEvalMouseChunk(MCExecContext& ctxt, MCStringRef& r_string)
791791

792792
void MCInterfaceEvalMouseLine(MCExecContext& ctxt, MCStringRef& r_string)
793793
{
794-
if (MCmousestackptr != nil)
794+
if (MCmousestackptr)
795795
{
796796
MCControl *mfocused = MCmousestackptr->getcard()->getmfocused();
797797
if (mfocused != NULL && mfocused->gettype() == CT_FIELD)
@@ -813,7 +813,7 @@ void MCInterfaceEvalMouseLine(MCExecContext& ctxt, MCStringRef& r_string)
813813
void MCInterfaceEvalMouseControl(MCExecContext& ctxt, MCStringRef& r_string)
814814
{
815815
MCControl *t_focused = nil;
816-
if (MCmousestackptr != nil)
816+
if (MCmousestackptr)
817817
t_focused = MCmousestackptr->getcard()->getmousecontrol();
818818

819819
if (t_focused == nil)
@@ -835,7 +835,7 @@ void MCInterfaceEvalMouseControl(MCExecContext& ctxt, MCStringRef& r_string)
835835

836836
void MCInterfaceEvalMouseStack(MCExecContext& ctxt, MCStringRef& r_string)
837837
{
838-
if (MCmousestackptr == nil)
838+
if (!MCmousestackptr)
839839
{
840840
r_string = MCValueRetain(kMCEmptyString);
841841
return;
@@ -1866,9 +1866,10 @@ void MCInterfaceExecClickCmd(MCExecContext& ctxt, uint2 p_button, MCPoint p_loca
18661866
MCmodifierstate = p_modifiers;
18671867
MCbuttonstate |= 0x1L << (p_button - 1);
18681868
MCdispatcher->wmdown_stack(MCdefaultstackptr, p_button);
1869-
// **** NULL POINTER FIX
1870-
if (MCmousestackptr != NULL)
1869+
1870+
if (MCmousestackptr)
18711871
MCscreen->sync(MCmousestackptr->getw());
1872+
18721873
Boolean abort = MCscreen->wait(CLICK_INTERVAL, False, False);
18731874

18741875
MCscreen->setclickloc(MCdefaultstackptr, t_view_clickloc);
@@ -2926,11 +2927,12 @@ void MCInterfaceExecPopupWidget(MCExecContext &ctxt, MCNameRef p_kind, MCPoint *
29262927

29272928
void MCInterfaceExecPopupButton(MCExecContext& ctxt, MCButton *p_target, MCPoint *p_at)
29282929
{
2929-
if (MCmousestackptr == NULL)
2930+
if (!MCmousestackptr)
29302931
{
29312932
ctxt . LegacyThrow(EE_SUBWINDOW_NOSTACK);
29322933
return;
29332934
}
2935+
29342936
if (p_at != nil)
29352937
{
29362938
MCmousex = p_at -> x;
@@ -2985,7 +2987,7 @@ void MCInterfaceExecSubwindow(MCExecContext& ctxt, MCStack *p_target, MCStack *p
29852987
{
29862988
MCwatchcursor = False;
29872989
p_target->resetcursor(True);
2988-
if (MCmousestackptr != NULL && MCmousestackptr != p_target)
2990+
if (MCmousestackptr && MCmousestackptr != p_target)
29892991
MCmousestackptr->resetcursor(True);
29902992
}
29912993

@@ -4657,7 +4659,7 @@ void MCInterfaceExecGo(MCExecContext& ctxt, MCCard *p_card, MCStringRef p_window
46574659
MCtrace = oldtrace;
46584660
if (t_stack->getmode() == WM_TOP_LEVEL || t_stack->getmode() == WM_TOP_LEVEL_LOCKED)
46594661
MCdefaultstackptr = t_stack;
4660-
if (MCmousestackptr != NULL)
4662+
if (MCmousestackptr)
46614663
MCmousestackptr->resetcursor(True);
46624664
if (MCabortscript)
46634665
stat = ES_ERROR;

engine/src/exec-interface2.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ void MCInterfaceSetCursor(MCExecContext& ctxt, uinteger_t* p_value)
15221522
{
15231523
MCcursor = t_cursor;
15241524
MCcursorid = t_cursor_id;
1525-
if (MCmousestackptr != NULL)
1525+
if (MCmousestackptr)
15261526
MCmousestackptr->resetcursor(True);
15271527
else
15281528
MCdefaultstackptr->resetcursor(True);
@@ -1542,7 +1542,7 @@ void MCInterfaceSetDefaultCursor(MCExecContext& ctxt, uinteger_t p_value)
15421542
// PM-2015-06-17: [[ Bug 15200 ]] Default cursor should reset when set to empty, thus t_cursor *can* be nil
15431543
MCdefaultcursor = t_cursor;
15441544
MCdefaultcursorid = p_value;
1545-
if (MCmousestackptr != NULL)
1545+
if (MCmousestackptr)
15461546
MCmousestackptr->resetcursor(True);
15471547
else
15481548
MCdefaultstackptr->resetcursor(True);
@@ -2309,7 +2309,7 @@ void MCInterfaceEvalClickStackAsObject(MCExecContext& ctxt, MCObjectPtr& r_objec
23092309

23102310
void MCInterfaceEvalMouseStackAsObject(MCExecContext& ctxt, MCObjectPtr& r_object)
23112311
{
2312-
if (MCmousestackptr != nil)
2312+
if (MCmousestackptr)
23132313
{
23142314
r_object . object = MCmousestackptr;
23152315
r_object . part_id = 0;
@@ -2368,7 +2368,7 @@ void MCInterfaceEvalFoundFieldAsObject(MCExecContext& ctxt, MCObjectPtr& r_objec
23682368
void MCInterfaceEvalMouseControlAsObject(MCExecContext& ctxt, MCObjectPtr& r_object)
23692369
{
23702370
// OK-2009-01-19: Refactored to ensure behaviour is the same as the mouseControl.
2371-
if (MCmousestackptr != nil)
2371+
if (MCmousestackptr)
23722372
{
23732373
r_object . object = MCmousestackptr->getcard()->getmousecontrol();
23742374
r_object . part_id = 0;

engine/src/globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@ MCStacklist *MCtodestroy;
263263
MCCardlist *MCrecent;
264264
MCCardlist *MCcstack;
265265
MCDispatch *MCdispatcher;
266-
MCStack *MCmousestackptr;
267266
MCStack *MCclickstackptr;
268267
MCStack *MCfocusedstackptr;
269268
MCCard *MCdynamiccard;
270269
MCStackHandle MCtopstackptr;
271270
MCStackHandle MCdefaultstackptr;
272271
MCStackHandle MCstaticdefaultstackptr;
272+
MCStackHandle MCmousestackptr;
273273
Boolean MCdynamicpath;
274274
MCObject *MCerrorptr;
275275
MCObject *MCerrorlockptr;

engine/src/globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ extern MCStacklist *MCtodestroy;
181181
extern MCCardlist *MCrecent;
182182
extern MCCardlist *MCcstack;
183183
extern MCDispatch *MCdispatcher;
184-
extern MCStack *MCmousestackptr;
185184
extern MCStack *MCclickstackptr;
186185
extern MCStack *MCfocusedstackptr;
187186
extern MCStackHandle MCtopstackptr;
188187
extern MCStackHandle MCdefaultstackptr;
189188
extern MCStackHandle MCstaticdefaultstackptr;
189+
extern MCStackHandle MCmousestackptr;
190190
extern MCObjectPtr MCtargetptr;
191191
extern MCObject *MCmenuobjectptr;
192192
extern MCCard *MCdynamiccard;

engine/src/stack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ void MCStack::close()
767767
}
768768
if (MCmousestackptr == this)
769769
{
770-
MCmousestackptr = NULL;
770+
MCmousestackptr = nil;
771771
int2 x, y;
772772
MCscreen->querymouse(x, y);
773773
if (MCU_point_in_rect(curcard->getrect(), x, y))
@@ -1143,7 +1143,7 @@ void MCStack::mfocustake(MCControl *target)
11431143
void MCStack::munfocus(void)
11441144
{
11451145
if (MCmousestackptr == this)
1146-
MCmousestackptr = NULL;
1146+
MCmousestackptr = nil;
11471147
if (curcard != 0)
11481148
{
11491149
if (gettool(this) != T_SELECT)

engine/src/stack2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2198,7 +2198,7 @@ Exec_stat MCStack::openrect(const MCRectangle &rel, Window_mode wm, MCStack *par
21982198
}
21992199
else
22002200
{
2201-
if (MCmousestackptr == NULL)
2201+
if (!MCmousestackptr)
22022202
MCscreen->querymouse(trect.x, trect.y);
22032203
else
22042204
{

engine/src/uidc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ void MCUIDC::getmouseloc(MCStack *&r_target, MCPoint &r_loc)
376376
r_target = MCmousestackptr;
377377
r_loc = MCPointMake(MCmousex, MCmousey);
378378

379-
if (MCmousestackptr != nil)
379+
if (MCmousestackptr)
380380
r_loc = MCmousestackptr->stacktowindowloc(r_loc);
381381
}
382382

0 commit comments

Comments
 (0)