1
0
mirror of https://github.com/anope/anope.git synced 2026-07-08 00:43:12 +02:00

Put serialized_items on the heap to prevent weird crashes on shutdown from the list being destructed before members in it

This commit is contained in:
Adam
2011-10-10 15:04:23 -04:00
parent 9f3d735d9d
commit 80f4f317b2
5 changed files with 24 additions and 25 deletions
+8 -12
View File
@@ -60,7 +60,7 @@ namespace Serialize
class SerializableBase;
extern std::vector<SerializableBase *> serialized_types;
extern std::list<SerializableBase *> serialized_items;
extern std::list<SerializableBase *> *serialized_items;
extern void RegisterTypes();
class SerializableBase
@@ -85,11 +85,6 @@ template<typename Type> class Serializable : public SerializableBase
{
}
~SerializableAllocator()
{
Unregister();
}
void Register(const Anope::string &n, int pos = -1)
{
this->name = n;
@@ -127,20 +122,21 @@ template<typename Type> class Serializable : public SerializableBase
protected:
Serializable()
{
serialized_items.push_front(this);
this->s_iter = serialized_items.begin();
if (serialized_items == NULL)
serialized_items = new std::list<SerializableBase *>();
serialized_items->push_front(this);
this->s_iter = serialized_items->begin();
}
Serializable(const Serializable &)
{
serialized_items.push_front(this);
this->s_iter = serialized_items.begin();
serialized_items->push_front(this);
this->s_iter = serialized_items->begin();
}
~Serializable()
{
if (!serialized_items.empty())
serialized_items.erase(this->s_iter);
serialized_items->erase(this->s_iter);
}
public: