Fix occasional segfault upon loading snapshots.
Sometimes the situation could arise where a log ID referred to by a log entry's property list coincided with the temporary log ID associated with the object being created--usually resulting in an immediate segfault. Assigning the final log ID BEFORE setting the properties prevents this from happening.
This commit is contained in:
parent
71b0d4a867
commit
8a76b01db9
|
@ -336,8 +336,7 @@ Loggable::do_this ( const char *s, bool reverse )
|
||||||
|
|
||||||
{
|
{
|
||||||
/* create */
|
/* create */
|
||||||
Loggable *l = _class_map[ std::string( classname ) ]( e );
|
Loggable *l = _class_map[ std::string( classname ) ]( e, id );
|
||||||
l->update_id( id );
|
|
||||||
l->log_create();
|
l->log_create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef void (snapshot_func)( void * );
|
||||||
|
|
||||||
class Log_Entry;
|
class Log_Entry;
|
||||||
class Loggable;
|
class Loggable;
|
||||||
typedef Loggable *(create_func)(Log_Entry &);
|
typedef Loggable *(create_func)(Log_Entry &, int id);
|
||||||
|
|
||||||
#define LOG_REGISTER_CREATE( class ) \
|
#define LOG_REGISTER_CREATE( class ) \
|
||||||
Loggable::register_create( #class, & class ::create );
|
Loggable::register_create( #class, & class ::create );
|
||||||
|
@ -48,9 +48,10 @@ typedef Loggable *(create_func)(Log_Entry &);
|
||||||
|
|
||||||
#define LOG_CREATE_FUNC( class ) \
|
#define LOG_CREATE_FUNC( class ) \
|
||||||
static Loggable * \
|
static Loggable * \
|
||||||
create ( Log_Entry &e ) \
|
create ( Log_Entry &e, int id ) \
|
||||||
{ \
|
{ \
|
||||||
class *r = new class; \
|
class *r = new class; \
|
||||||
|
r->update_id( id ); \
|
||||||
r->set( e ); \
|
r->set( e ); \
|
||||||
return (Loggable *)r; \
|
return (Loggable *)r; \
|
||||||
} \
|
} \
|
||||||
|
|
Loading…
Reference in New Issue