mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +00:00
Fixed creation of BaseStatusBar
No more access to memory ouside of class instance Minimized amount of copy-pasted code https://mantis.zdoom.org/view.php?id=511
This commit is contained in:
parent
5601364aaf
commit
f48af606df
2 changed files with 19 additions and 19 deletions
|
@ -1546,11 +1546,6 @@ DBaseStatusBar *CreateCustomStatusBar(int scriptno)
|
|||
I_FatalError("Tried to create a status bar with no script!");
|
||||
|
||||
auto sbar = (DBaseStatusBar*)PClass::FindClass("SBarInfoWrapper")->CreateNew();
|
||||
IFVIRTUALPTR(sbar, DBaseStatusBar, Init)
|
||||
{
|
||||
VMValue params[] = { sbar };
|
||||
GlobalVMStack.Call(func, params, 1, nullptr, 0);
|
||||
}
|
||||
auto core = new DSBarInfo(sbar, script);
|
||||
sbar->PointerVar<DSBarInfo>("core") = core;
|
||||
sbar->SetSize(script->height, script->_resW, script->_resH);
|
||||
|
|
|
@ -251,6 +251,17 @@ void ST_Clear()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void CreateBaseStatusBar()
|
||||
{
|
||||
assert(nullptr == StatusBar);
|
||||
|
||||
PClass* const statusBarClass = PClass::FindClass("BaseStatusBar");
|
||||
assert(nullptr != statusBarClass);
|
||||
|
||||
StatusBar = static_cast<DBaseStatusBar*>(statusBarClass->CreateNew());
|
||||
StatusBar->SetSize(0);
|
||||
}
|
||||
|
||||
void ST_CreateStatusBar(bool bTitleLevel)
|
||||
{
|
||||
if (StatusBar != NULL)
|
||||
|
@ -261,8 +272,7 @@ void ST_CreateStatusBar(bool bTitleLevel)
|
|||
|
||||
if (bTitleLevel)
|
||||
{
|
||||
StatusBar = new DBaseStatusBar();
|
||||
StatusBar->SetSize(0);
|
||||
CreateBaseStatusBar();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -277,11 +287,6 @@ void ST_CreateStatusBar(bool bTitleLevel)
|
|||
if (cls != nullptr)
|
||||
{
|
||||
StatusBar = (DBaseStatusBar *)cls->CreateNew();
|
||||
IFVIRTUALPTR(StatusBar, DBaseStatusBar, Init)
|
||||
{
|
||||
VMValue params[] = { StatusBar };
|
||||
GlobalVMStack.Call(func, params, 1, nullptr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -313,18 +318,18 @@ void ST_CreateStatusBar(bool bTitleLevel)
|
|||
if (cls != nullptr)
|
||||
{
|
||||
StatusBar = (DBaseStatusBar *)cls->CreateNew();
|
||||
IFVIRTUALPTR(StatusBar, DBaseStatusBar, Init)
|
||||
{
|
||||
VMValue params[] = { StatusBar };
|
||||
GlobalVMStack.Call(func, params, 1, nullptr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StatusBar == nullptr)
|
||||
{
|
||||
StatusBar = new DBaseStatusBar();
|
||||
StatusBar->SetSize(0);
|
||||
CreateBaseStatusBar();
|
||||
}
|
||||
|
||||
IFVIRTUALPTR(StatusBar, DBaseStatusBar, Init)
|
||||
{
|
||||
VMValue params[] = { StatusBar };
|
||||
GlobalVMStack.Call(func, params, 1, nullptr, 0);
|
||||
}
|
||||
|
||||
GC::WriteBarrier(StatusBar);
|
||||
|
|
Loading…
Reference in a new issue