mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +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
|
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
|
std::string AObjectTypeHandler::getJsonKey() const
|
||||||
{
|
{
|
||||||
return modScope + ':' + subTypeName;
|
return modScope + ':' + subTypeName;
|
||||||
@ -55,7 +68,8 @@ static ui32 loadJsonOrMax(const JsonNode & input)
|
|||||||
|
|
||||||
void AObjectTypeHandler::init(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())
|
if (!input["rmg"].isNull())
|
||||||
{
|
{
|
||||||
@ -72,7 +86,8 @@ void AObjectTypeHandler::init(const JsonNode & input)
|
|||||||
for (auto entry : input["templates"].Struct())
|
for (auto entry : input["templates"].Struct())
|
||||||
{
|
{
|
||||||
entry.second.setType(JsonNode::JsonType::DATA_STRUCT);
|
entry.second.setType(JsonNode::JsonType::DATA_STRUCT);
|
||||||
JsonUtils::inherit(entry.second, base);
|
if (base)
|
||||||
|
JsonUtils::inherit(entry.second, *base);
|
||||||
|
|
||||||
auto * tmpl = new ObjectTemplate;
|
auto * tmpl = new ObjectTemplate;
|
||||||
tmpl->id = Obj(type);
|
tmpl->id = Obj(type);
|
||||||
@ -171,7 +186,8 @@ void AObjectTypeHandler::addTemplate(const std::shared_ptr<const ObjectTemplate>
|
|||||||
void AObjectTypeHandler::addTemplate(JsonNode config)
|
void AObjectTypeHandler::addTemplate(JsonNode config)
|
||||||
{
|
{
|
||||||
config.setType(JsonNode::JsonType::DATA_STRUCT); // ensure that input is not null
|
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;
|
auto * tmpl = new ObjectTemplate;
|
||||||
tmpl->id = Obj(type);
|
tmpl->id = Obj(type);
|
||||||
tmpl->subid = subtype;
|
tmpl->subid = subtype;
|
||||||
|
@ -27,7 +27,7 @@ class DLL_LINKAGE AObjectTypeHandler : public boost::noncopyable
|
|||||||
|
|
||||||
RandomMapInfo rmgInfo;
|
RandomMapInfo rmgInfo;
|
||||||
|
|
||||||
JsonNode base; /// describes base template
|
std::unique_ptr<JsonNode> base; /// describes base template
|
||||||
|
|
||||||
std::vector<std::shared_ptr<const ObjectTemplate>> templates;
|
std::vector<std::shared_ptr<const ObjectTemplate>> templates;
|
||||||
|
|
||||||
@ -54,7 +54,8 @@ protected:
|
|||||||
virtual void initTypeData(const JsonNode & input);
|
virtual void initTypeData(const JsonNode & input);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~AObjectTypeHandler() = default;
|
AObjectTypeHandler();
|
||||||
|
virtual ~AObjectTypeHandler();
|
||||||
|
|
||||||
si32 getIndex() const;
|
si32 getIndex() const;
|
||||||
si32 getSubIndex() const;
|
si32 getSubIndex() const;
|
||||||
|
@ -443,7 +443,6 @@ void CObjectClassesHandler::generateExtraMonolithsForRMG(ObjectClass * container
|
|||||||
//deep copy of noncopyable object :?
|
//deep copy of noncopyable object :?
|
||||||
auto newPortal = std::make_shared<CDefaultObjectTypeHandler<CGMonolith>>();
|
auto newPortal = std::make_shared<CDefaultObjectTypeHandler<CGMonolith>>();
|
||||||
newPortal->rmgInfo = portal->getRMGInfo();
|
newPortal->rmgInfo = portal->getRMGInfo();
|
||||||
newPortal->base = portal->base; //not needed?
|
|
||||||
newPortal->templates = portal->getTemplates();
|
newPortal->templates = portal->getTemplates();
|
||||||
newPortal->sounds = portal->getSounds();
|
newPortal->sounds = portal->getSounds();
|
||||||
newPortal->aiValue = portal->getAiValue();
|
newPortal->aiValue = portal->getAiValue();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user