mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Attempt to track down mystery crash on Android
This commit is contained in:
parent
6a357aaea6
commit
496bca1a59
@ -20,6 +20,19 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
AObjectTypeHandler::AObjectTypeHandler() = default;
|
||||
|
||||
AObjectTypeHandler::~AObjectTypeHandler()
|
||||
{
|
||||
// FIXME: currently on Android there is a weird crash in destructor of 'base' member
|
||||
// this code attempts to localize and fix this crash
|
||||
if (base)
|
||||
{
|
||||
base->clear();
|
||||
base.reset();
|
||||
}
|
||||
}
|
||||
|
||||
std::string AObjectTypeHandler::getJsonKey() const
|
||||
{
|
||||
return modScope + ':' + subTypeName;
|
||||
@ -55,7 +68,8 @@ static ui32 loadJsonOrMax(const JsonNode & input)
|
||||
|
||||
void AObjectTypeHandler::init(const JsonNode & input)
|
||||
{
|
||||
base = input["base"];
|
||||
if (!input["base"].isNull())
|
||||
base = std::make_unique<JsonNode>(input["base"]);
|
||||
|
||||
if (!input["rmg"].isNull())
|
||||
{
|
||||
@ -72,7 +86,8 @@ void AObjectTypeHandler::init(const JsonNode & input)
|
||||
for (auto entry : input["templates"].Struct())
|
||||
{
|
||||
entry.second.setType(JsonNode::JsonType::DATA_STRUCT);
|
||||
JsonUtils::inherit(entry.second, base);
|
||||
if (base)
|
||||
JsonUtils::inherit(entry.second, *base);
|
||||
|
||||
auto * tmpl = new ObjectTemplate;
|
||||
tmpl->id = Obj(type);
|
||||
@ -171,7 +186,8 @@ void AObjectTypeHandler::addTemplate(const std::shared_ptr<const ObjectTemplate>
|
||||
void AObjectTypeHandler::addTemplate(JsonNode config)
|
||||
{
|
||||
config.setType(JsonNode::JsonType::DATA_STRUCT); // ensure that input is not null
|
||||
JsonUtils::inherit(config, base);
|
||||
if (base)
|
||||
JsonUtils::inherit(config, *base);
|
||||
auto * tmpl = new ObjectTemplate;
|
||||
tmpl->id = Obj(type);
|
||||
tmpl->subid = subtype;
|
||||
|
@ -27,7 +27,7 @@ class DLL_LINKAGE AObjectTypeHandler : public boost::noncopyable
|
||||
|
||||
RandomMapInfo rmgInfo;
|
||||
|
||||
JsonNode base; /// describes base template
|
||||
std::unique_ptr<JsonNode> base; /// describes base template
|
||||
|
||||
std::vector<std::shared_ptr<const ObjectTemplate>> templates;
|
||||
|
||||
@ -54,7 +54,8 @@ protected:
|
||||
virtual void initTypeData(const JsonNode & input);
|
||||
public:
|
||||
|
||||
virtual ~AObjectTypeHandler() = default;
|
||||
AObjectTypeHandler();
|
||||
virtual ~AObjectTypeHandler();
|
||||
|
||||
si32 getIndex() const;
|
||||
si32 getSubIndex() const;
|
||||
|
@ -443,7 +443,6 @@ void CObjectClassesHandler::generateExtraMonolithsForRMG(ObjectClass * container
|
||||
//deep copy of noncopyable object :?
|
||||
auto newPortal = std::make_shared<CDefaultObjectTypeHandler<CGMonolith>>();
|
||||
newPortal->rmgInfo = portal->getRMGInfo();
|
||||
newPortal->base = portal->base; //not needed?
|
||||
newPortal->templates = portal->getTemplates();
|
||||
newPortal->sounds = portal->getSounds();
|
||||
newPortal->aiValue = portal->getAiValue();
|
||||
|
Loading…
x
Reference in New Issue
Block a user