mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
Marked internal menu commands as safe
This fixes soundfont/patchset/config selection menus in advanced sound options
This commit is contained in:
parent
c8b6e5719e
commit
d9323b9740
3 changed files with 9 additions and 3 deletions
|
@ -692,7 +692,8 @@ DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand)
|
|||
if (CurrentMenu == nullptr) return 0;
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_STRING(cmd);
|
||||
UnsafeExecutionScope scope;
|
||||
PARAM_BOOL(unsafe);
|
||||
UnsafeExecutionScope scope(unsafe);
|
||||
C_DoCommand(cmd);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "vm.h"
|
||||
#include "events.h"
|
||||
#include "gl/renderer/gl_renderer.h" // for menu blur
|
||||
#include "scripting/types.h"
|
||||
|
||||
//
|
||||
// Todo: Move these elsewhere
|
||||
|
@ -1180,6 +1181,8 @@ DMenuItemBase * CreateOptionMenuItemCommand(const char *label, FName cmd, bool c
|
|||
VMValue params[] = { p, &namestr, cmd.GetIndex(), centered };
|
||||
auto f = dyn_cast<PFunction>(c->FindSymbol("Init", false));
|
||||
VMCall(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
|
||||
auto unsafe = dyn_cast<PField>(c->FindSymbol("mUnsafe", false));
|
||||
unsafe->Type->SetValue(reinterpret_cast<uint8_t*>(p) + unsafe->Offset, 0);
|
||||
return (DMenuItemBase*)p;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,16 +128,18 @@ class OptionMenuItemCommand : OptionMenuItemSubmenu
|
|||
{
|
||||
private String ccmd; // do not allow access to this from the outside.
|
||||
bool mCloseOnSelect;
|
||||
private bool mUnsafe;
|
||||
|
||||
OptionMenuItemCommand Init(String label, Name command, bool centered = false, bool closeonselect = false)
|
||||
{
|
||||
Super.Init(label, command, 0, centered);
|
||||
ccmd = command;
|
||||
mCloseOnSelect = closeonselect;
|
||||
mUnsafe = true;
|
||||
return self;
|
||||
}
|
||||
|
||||
private native static void DoCommand(String cmd); // This is very intentionally limited to this menu item to prevent abuse.
|
||||
private native static void DoCommand(String cmd, bool unsafe); // This is very intentionally limited to this menu item to prevent abuse.
|
||||
|
||||
override bool Activate()
|
||||
{
|
||||
|
@ -151,7 +153,7 @@ class OptionMenuItemCommand : OptionMenuItemSubmenu
|
|||
if (m.GetItem(mAction) != self) return false;
|
||||
}
|
||||
Menu.MenuSound("menu/choose");
|
||||
DoCommand(ccmd);
|
||||
DoCommand(ccmd, mUnsafe);
|
||||
if (mCloseOnSelect)
|
||||
{
|
||||
let curmenu = Menu.GetCurrentMenu();
|
||||
|
|
Loading…
Reference in a new issue