mirror of
https://github.com/anope/anope.git
synced 2026-06-29 17:16:38 +02:00
Delay running the type creation event until after initialisation.
Doing this during the ctor can run into circumstances where the vtable has not been fully initialised and the call gets routed to the pure virtual implementation causing a crash.
This commit is contained in:
+18
-6
@@ -38,14 +38,19 @@ void Serialize::RegisterTypes()
|
||||
static AutoKick::Type akick;
|
||||
static Memo::Type memo;
|
||||
static XLine::Type xline;
|
||||
CreateTypes();
|
||||
}
|
||||
|
||||
void Serialize::CreateTypes()
|
||||
{
|
||||
for (const auto &[_, s_type] : Serialize::Type::GetTypes())
|
||||
s_type->Create();
|
||||
}
|
||||
|
||||
void Serialize::CheckTypes()
|
||||
{
|
||||
for (const auto &[_, t] : Serialize::Type::GetTypes())
|
||||
{
|
||||
t->Check();
|
||||
}
|
||||
for (const auto &[_, s_type] : Serialize::Type::GetTypes())
|
||||
s_type->Check();
|
||||
}
|
||||
|
||||
Serializable::Serializable(const Anope::string &serialize_type)
|
||||
@@ -138,8 +143,6 @@ Type::Type(const Anope::string &n, Module *o)
|
||||
{
|
||||
TypeOrder.push_back(this->name);
|
||||
Types[this->name] = this;
|
||||
|
||||
FOREACH_MOD(OnSerializeTypeCreate, (this));
|
||||
}
|
||||
|
||||
Type::~Type()
|
||||
@@ -160,6 +163,15 @@ Type::~Type()
|
||||
Types.erase(this->name);
|
||||
}
|
||||
|
||||
void Type::Create()
|
||||
{
|
||||
if (created)
|
||||
return;
|
||||
|
||||
FOREACH_MOD(OnSerializeTypeCreate, (this));
|
||||
created = true;
|
||||
}
|
||||
|
||||
void Type::Check()
|
||||
{
|
||||
FOREACH_MOD(OnSerializeCheck, (this));
|
||||
|
||||
Reference in New Issue
Block a user