Skip to content

Commit 0d66c07

Browse files
committed
[Bug 15970] New logic for choosing stack file saving format
If no stack format is requested, try to use the latest one available. If a specific stack file format is requested, try to save in that format, and produce an error if doing so would cause data loss. At the moment, this means that saving a stack produces an error if the stack contains widgets and 8.0 format wasn't requested. If 8.0 stack format is requested, but no widgets are present, use 7.0 format. Set the `stackfileversion` to "8.0" by default, so that `save stack` preserves widgets.
1 parent 2834680 commit 0d66c07

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

engine/src/dispatch.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,20 +1066,22 @@ IO_stat MCDispatch::savestack(MCStack *sptr, const MCStringRef p_fname, uint32_t
10661066
}
10671067
else
10681068
{
1069-
// MW-2014-12-17: [[ Widgets ]] Force writing out as 8.0 version stack if it
1070-
// contains widgets, and only write out as 8.0 if it contains widgets.
1071-
uint32_t t_old_stackfileversion;
1072-
t_old_stackfileversion = MCstackfileversion;
1073-
if (sptr -> haswidgets() || sptr -> substackhaswidgets())
1074-
MCstackfileversion = 8000;
1075-
else if (MCstackfileversion == 8000)
1076-
MCstackfileversion = 7000;
1077-
1078-
stat = dosavestack(sptr, p_fname, MCstackfileversion);
1069+
/* If no version was specified, assume that 8.0 format was requested */
1070+
if (UINT32_MAX == p_version)
1071+
{
1072+
p_version = 8000;
1073+
}
1074+
1075+
/* If the stack doesn't contain widgets, and 8.0 format was requested,
1076+
* use 7.0 format. */
1077+
if (8000 == p_version && !sptr->haswidgets())
1078+
{
1079+
p_version = 7000;
1080+
}
1081+
1082+
stat = dosavestack(sptr, p_fname, p_version);
10791083

10801084
MCLogicalFontTableFinish();
1081-
1082-
MCstackfileversion = t_old_stackfileversion;
10831085
}
10841086

10851087
return stat;

engine/src/globals.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ MCPlatformSoundRecorderRef MCrecorder;
384384
#endif
385385

386386
// AL-2014-18-02: [[ UnicodeFileFormat ]] Make stackfile version 7.0 the default.
387-
uint4 MCstackfileversion = 7000;
387+
uint4 MCstackfileversion = 8000;
388388
uint2 MClook;
389389
MCStringRef MCttbgcolor;
390390
MCStringRef MCttfont;
@@ -764,7 +764,7 @@ void X_clear_globals(void)
764764
#endif
765765

766766
// AL-2014-18-02: [[ UnicodeFileFormat ]] Make 7.0 stackfile version the default.
767-
MCstackfileversion = 7000;
767+
MCstackfileversion = 8000;
768768

769769
MClook = LF_MOTIF;
770770
MCttbgcolor = MCSTR("255,255,207");

0 commit comments

Comments
 (0)