- added write barriers to the menu code.

The GC was causing some crash issues with the items not having been subjected to a write barrier.
This commit is contained in:
Christoph Oelckers 2017-02-05 01:52:09 +01:00
parent 470dc138c6
commit 5cfac78116
6 changed files with 47 additions and 0 deletions

View file

@ -89,6 +89,10 @@ public:
desc->mItems[mStartItem+5] = new DOptionMenuItemStaticText(" ", false);
desc->mItems[mStartItem+6] = new DOptionMenuItemCommand("Undo changes", "undocolorpic");
desc->mItems[mStartItem+7] = new DOptionMenuItemStaticText(" ", false);
for (auto &p : desc->mItems)
{
GC::WriteBarrier(p);
}
desc->mSelectedItem = mStartItem + 2;
Init(parent, desc);
desc->mIndent = 0;

View file

@ -322,6 +322,10 @@ FOptionMenuDescriptor *UpdateJoystickConfigMenu(IJoystickConfig *joy)
opt->mItems.Push(it);
}
}
for (auto &p : opt->mItems)
{
GC::WriteBarrier(p);
}
opt->mScrollPos = 0;
opt->mSelectedItem = -1;
opt->mIndent = 0;
@ -402,6 +406,10 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
if (i == itemnum) opt->mSelectedItem = opt->mItems.Size();
}
}
for (auto &p : opt->mItems)
{
GC::WriteBarrier(p);
}
if (opt->mSelectedItem >= (int)opt->mItems.Size())
{
opt->mSelectedItem = opt->mItems.Size() - 1;

View file

@ -44,6 +44,10 @@
IMPLEMENT_CLASS(DListMenu, false, false)
IMPLEMENT_POINTERS_START(DListMenu)
IMPLEMENT_POINTER(mFocusControl)
IMPLEMENT_POINTERS_END
//=============================================================================
//
//

View file

@ -520,6 +520,7 @@ public:
class DListMenu : public DMenu
{
DECLARE_CLASS(DListMenu, DMenu)
HAS_OBJECT_POINTERS;
protected:
FListMenuDescriptor *mDesc;
@ -609,6 +610,7 @@ extern FOptionMap OptionValues;
class DOptionMenu : public DMenu
{
DECLARE_CLASS(DOptionMenu, DMenu)
HAS_OBJECT_POINTERS;
bool CanScrollUp;
bool CanScrollDown;

View file

@ -475,6 +475,10 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc)
sc.ScriptError("Unknown keyword '%s'", sc.String);
}
}
for (auto &p : desc->mItems)
{
GC::WriteBarrier(p);
}
}
//=============================================================================
@ -927,6 +931,10 @@ static void ParseOptionMenuBody(FScanner &sc, FOptionMenuDescriptor *desc)
sc.ScriptError("Unknown keyword '%s'", sc.String);
}
}
for (auto &p : desc->mItems)
{
GC::WriteBarrier(p);
}
}
//=============================================================================
@ -1101,6 +1109,10 @@ static void BuildEpisodeMenu()
ld->mAutoselect = ld->mSelectedItem;
}
success = true;
for (auto &p : ld->mItems)
{
GC::WriteBarrier(p);
}
}
}
}
@ -1125,6 +1137,7 @@ static void BuildEpisodeMenu()
{
DOptionMenuItemSubmenu *it = new DOptionMenuItemSubmenu(AllEpisodes[i].mEpisodeName, "Skillmenu", i);
od->mItems.Push(it);
GC::WriteBarrier(it);
}
}
}
@ -1230,6 +1243,10 @@ static void BuildPlayerclassMenu()
}
}
success = true;
for (auto &p : ld->mItems)
{
GC::WriteBarrier(p);
}
}
}
}
@ -1261,11 +1278,13 @@ static void BuildPlayerclassMenu()
{
DOptionMenuItemSubmenu *it = new DOptionMenuItemSubmenu(pname, "Episodemenu", i);
od->mItems.Push(it);
GC::WriteBarrier(it);
}
}
}
DOptionMenuItemSubmenu *it = new DOptionMenuItemSubmenu("Random", "Episodemenu", -1);
od->mItems.Push(it);
GC::WriteBarrier(it);
}
}
@ -1355,6 +1374,10 @@ static void InitKeySections()
menu->mItems.Push(item);
}
}
for (auto &p : menu->mItems)
{
GC::WriteBarrier(p);
}
}
}
}
@ -1488,6 +1511,7 @@ void M_StartupSkillMenu(FGameStartup *gs)
pItemText? *pItemText : skill.MenuName, ld->mFont, color,ld->mFontColor2, action, i);
}
ld->mItems.Push(li);
GC::WriteBarrier(li);
y += ld->mLinespacing;
}
if (AllEpisodes[gs->Episode].mNoSkill || AllSkills.Size() == 1)
@ -1541,6 +1565,7 @@ fail:
}
li = new DOptionMenuItemSubmenu(pItemText? *pItemText : skill.MenuName, action, i);
od->mItems.Push(li);
GC::WriteBarrier(li);
if (!done)
{
done = true;

View file

@ -66,6 +66,10 @@ void M_DrawConText (int color, int x, int y, const char *str)
IMPLEMENT_CLASS(DOptionMenu, false, false)
IMPLEMENT_POINTERS_START(DOptionMenu)
IMPLEMENT_POINTER(mFocusControl)
IMPLEMENT_POINTERS_END
//=============================================================================
//
//