Skip to content

Commit 845136b

Browse files
committed
[[ Bug 13569 ]] Different approach by detaching players before preopencard messages are sent, and re-attaching them after
1 parent 687f008 commit 845136b

3 files changed

Lines changed: 58 additions & 18 deletions

File tree

engine/src/player-platform.cpp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,10 @@ MCPlayer::MCPlayer()
871871
// MW-2014-07-16: [[ Bug ]] Put the player in the list.
872872
nextplayer = MCplayers;
873873
MCplayers = this;
874+
875+
// PM-2104-10-14: [[ Bug 13569 ]] Make sure changes to player in preOpenCard are not visible
876+
m_is_attached = false;
877+
m_should_attach = false;
874878
}
875879

876880
MCPlayer::MCPlayer(const MCPlayer &sref) : MCControl(sref)
@@ -960,6 +964,8 @@ void MCPlayer::open()
960964
{
961965
MCControl::open();
962966
prepare(MCnullstring);
967+
MCPlatformAttachPlayer(m_platform_player, getstack() -> getwindow());
968+
m_is_attached = true;;
963969
}
964970

965971
void MCPlayer::close()
@@ -974,6 +980,9 @@ void MCPlayer::close()
974980

975981
if (s_volume_popup != nil)
976982
s_volume_popup -> close();
983+
984+
MCPlatformDetachPlayer(m_platform_player);
985+
m_is_attached = false;
977986
}
978987

979988
Boolean MCPlayer::kdown(const char *string, KeySym key)
@@ -2100,7 +2109,8 @@ Boolean MCPlayer::prepare(const char *options)
21002109
t_visible = getflag(F_VISIBLE);
21012110
MCPlatformSetPlayerProperty(m_platform_player, kMCPlatformPlayerPropertyVisible, kMCPlatformPropertyTypeBool, &t_visible);
21022111

2103-
MCPlatformAttachPlayer(m_platform_player, getstack() -> getwindow());
2112+
//attachplayer();
2113+
m_is_attached = false;
21042114

21052115
layer_redrawall();
21062116

@@ -2118,6 +2128,35 @@ Boolean MCPlayer::prepare(const char *options)
21182128
return ok;
21192129
}
21202130

2131+
// PM-2014-10-14: [[ Bug 13569 ]] Make sure changes to player are not visible in preOpenCard
2132+
void MCPlayer::attachplayer()
2133+
{
2134+
if (m_platform_player == nil)
2135+
return;
2136+
2137+
// Make sure we attach the player only if it was previously detached by detachplayer().
2138+
if (!m_is_attached && m_should_attach)
2139+
{
2140+
MCPlatformAttachPlayer(m_platform_player, getstack() -> getwindow());
2141+
m_is_attached = true;
2142+
m_should_attach = false;
2143+
}
2144+
}
2145+
2146+
// PM-2014-10-14: [[ Bug 13569 ]] Make sure changes to player are not visible in preOpenCard
2147+
void MCPlayer::detachplayer()
2148+
{
2149+
if (m_platform_player == nil)
2150+
return;
2151+
2152+
if (m_is_attached)
2153+
{
2154+
MCPlatformDetachPlayer(m_platform_player);
2155+
m_is_attached = false;
2156+
m_should_attach = true;
2157+
}
2158+
}
2159+
21212160
Boolean MCPlayer::playstart(const char *options)
21222161
{
21232162
if (!prepare(options))
@@ -2208,6 +2247,7 @@ Boolean MCPlayer::playstop()
22082247
needmessage = getduration() > getmoviecurtime();
22092248

22102249
MCPlatformDetachPlayer(m_platform_player);
2250+
m_is_attached = false;
22112251
}
22122252

22132253
redrawcontroller();

engine/src/player-platform.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ class MCPlayer : public MCControl
8686
bool m_scrub_back_is_pressed : 1;
8787
bool m_scrub_forward_is_pressed : 1;
8888
bool m_modify_selection_while_playing : 1;
89+
bool m_is_attached : 1;
90+
bool m_should_attach : 1;
8991

9092
public:
9193
MCPlayer();
@@ -266,6 +268,10 @@ class MCPlayer : public MCControl
266268
void handle_mfocus(int x, int y);
267269

268270
void popup_closed(void);
271+
272+
// PM-2014-10-14: [[ Bug 13569 ]] Make sure changes to player are not visible in preOpenCard
273+
void attachplayer(void);
274+
void detachplayer(void);
269275
};
270276

271277
#endif

engine/src/stack3.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ Exec_stat MCStack::setcard(MCCard *card, Boolean recent, Boolean dynamic)
10071007
// MW-2011-09-14: [[ Redraw ]] We lock the screen between before closeCard and until
10081008
// after preOpenCard.
10091009
MCRedrawLockScreen();
1010-
1010+
10111011
MCCard *oldcard = curcard;
10121012
Boolean oldlock = MClockmessages;
10131013
if (card != oldcard)
@@ -1077,29 +1077,23 @@ Exec_stat MCStack::setcard(MCCard *card, Boolean recent, Boolean dynamic)
10771077

10781078
if (!t_error)
10791079
{
1080-
// PM-2014-10-13: [[ Bug 13569 ]] Hide player to avoid redraw issue on preOpenCard
1080+
// PM-2014-10-13: [[ Bug 13569 ]] Detach all players before any messages are sent
10811081
for(MCPlayer *t_player = MCplayers; t_player != nil; t_player = t_player -> getnextplayer())
10821082
if (t_player -> getstack() == curcard -> getstack())
1083-
{
1084-
MCExecPoint ep(nil,nil,nil);
1085-
ep.setboolean(False);
1086-
t_player -> setprop(0, P_VISIBLE, ep, False);
1087-
}
1088-
1083+
t_player -> detachplayer();
1084+
10891085
t_error = curcard->message(MCM_preopen_card) == ES_ERROR || curcard != card || !opened;
1090-
1091-
// PM-2014-10-13: [[ Bug 13569 ]] when preOpenCard handler finish, show the player
1092-
for(MCPlayer *t_player = MCplayers; t_player != nil; t_player = t_player -> getnextplayer())
1093-
if (t_player -> getstack() == curcard -> getstack())
1094-
{
1095-
MCExecPoint ep(nil,nil,nil);
1096-
ep.setboolean(True);
1097-
t_player -> setprop(0, P_VISIBLE, ep, False);
1098-
}
10991086
}
11001087

11011088
if (!t_error)
1089+
{
11021090
t_error = curcard -> opencontrols(true) == ES_ERROR || curcard != card || !opened;
1091+
1092+
// PM-2014-10-13: [[ Bug 13569 ]] after any messages are sent, attach all players previously detached
1093+
for(MCPlayer *t_player = MCplayers; t_player != nil; t_player = t_player -> getnextplayer())
1094+
if (t_player -> getstack() == curcard -> getstack())
1095+
t_player -> attachplayer();
1096+
}
11031097

11041098
if (t_error)
11051099
{

0 commit comments

Comments
 (0)