mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Do not crash on invalid callback name
This commit is contained in:
@@ -297,7 +297,14 @@ std::shared_ptr<CToggleButton> InterfaceObjectConfigurable::buildToggleButton(co
|
|||||||
button->setImageOrder(imgOrder[0].Integer(), imgOrder[1].Integer(), imgOrder[2].Integer(), imgOrder[3].Integer());
|
button->setImageOrder(imgOrder[0].Integer(), imgOrder[1].Integer(), imgOrder[2].Integer(), imgOrder[3].Integer());
|
||||||
}
|
}
|
||||||
if(!config["callback"].isNull())
|
if(!config["callback"].isNull())
|
||||||
button->addCallback(callbacks.at(config["callback"].String()));
|
{
|
||||||
|
std::string callbackName = config["callback"].String();
|
||||||
|
|
||||||
|
if (callbacks.count(callbackName))
|
||||||
|
button->addCallback(callbacks.at(callbackName));
|
||||||
|
else
|
||||||
|
logGlobal->error("Invalid callback '%s' in widget", callbackName );
|
||||||
|
}
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user