mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 08:31:45 +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!");
|
I_FatalError("Tried to create a status bar with no script!");
|
||||||
|
|
||||||
auto sbar = (DBaseStatusBar*)PClass::FindClass("SBarInfoWrapper")->CreateNew();
|
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);
|
auto core = new DSBarInfo(sbar, script);
|
||||||
sbar->PointerVar<DSBarInfo>("core") = core;
|
sbar->PointerVar<DSBarInfo>("core") = core;
|
||||||
sbar->SetSize(script->height, script->_resW, script->_resH);
|
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)
|
void ST_CreateStatusBar(bool bTitleLevel)
|
||||||
{
|
{
|
||||||
if (StatusBar != NULL)
|
if (StatusBar != NULL)
|
||||||
|
@ -261,8 +272,7 @@ void ST_CreateStatusBar(bool bTitleLevel)
|
||||||
|
|
||||||
if (bTitleLevel)
|
if (bTitleLevel)
|
||||||
{
|
{
|
||||||
StatusBar = new DBaseStatusBar();
|
CreateBaseStatusBar();
|
||||||
StatusBar->SetSize(0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -277,11 +287,6 @@ void ST_CreateStatusBar(bool bTitleLevel)
|
||||||
if (cls != nullptr)
|
if (cls != nullptr)
|
||||||
{
|
{
|
||||||
StatusBar = (DBaseStatusBar *)cls->CreateNew();
|
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)
|
if (cls != nullptr)
|
||||||
{
|
{
|
||||||
StatusBar = (DBaseStatusBar *)cls->CreateNew();
|
StatusBar = (DBaseStatusBar *)cls->CreateNew();
|
||||||
IFVIRTUALPTR(StatusBar, DBaseStatusBar, Init)
|
|
||||||
{
|
|
||||||
VMValue params[] = { StatusBar };
|
|
||||||
GlobalVMStack.Call(func, params, 1, nullptr, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StatusBar == nullptr)
|
if (StatusBar == nullptr)
|
||||||
{
|
{
|
||||||
StatusBar = new DBaseStatusBar();
|
CreateBaseStatusBar();
|
||||||
StatusBar->SetSize(0);
|
}
|
||||||
|
|
||||||
|
IFVIRTUALPTR(StatusBar, DBaseStatusBar, Init)
|
||||||
|
{
|
||||||
|
VMValue params[] = { StatusBar };
|
||||||
|
GlobalVMStack.Call(func, params, 1, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
GC::WriteBarrier(StatusBar);
|
GC::WriteBarrier(StatusBar);
|
||||||
|
|
Loading…
Reference in a new issue