From df344dc0650467aeb7b53508caeb4402e9cfe534 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 7 Sep 2009 19:53:04 -0500 Subject: [PATCH] Assert whenever an invalid journal entry is encountered. --- Timeline/Loggable.C | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Timeline/Loggable.C b/Timeline/Loggable.C index e5e802d..73ac0d8 100644 --- a/Timeline/Loggable.C +++ b/Timeline/Loggable.C @@ -322,16 +322,14 @@ Loggable::do_this ( const char *s, bool reverse ) { unsigned int id = 0; - if ( ! ( sscanf( s, "%*s %X ", &id ) > 0 ) ) - return false; - - Loggable *l = find( id ); -// assert( l ); - char classname[40]; char command[40]; char *arguments = NULL; + int found = sscanf( s, "%s %X %s ", classname, &id, command ); + + ASSERT( 3 == found, "Invalid journal entry format \"%s\"", s ); + const char *create, *destroy; if ( reverse ) @@ -352,6 +350,8 @@ Loggable::do_this ( const char *s, bool reverse ) if ( ! strcmp( command, destroy ) ) { + Loggable *l = find( id ); + /* deleting eg. a track, which contains a list of other widgets, causes destroy messages to be emitted for all those widgets, but when replaying the journal the destroy message @@ -365,6 +365,10 @@ Loggable::do_this ( const char *s, bool reverse ) { // printf( "got set command (%s).\n", arguments ); + Loggable *l = find( id ); + + ASSERT( l, "Unable to find object 0x%X referenced by command \"%s\"", id, s ); + Log_Entry e( arguments ); l->log_start(); @@ -687,8 +691,8 @@ Loggable::log_create ( void ) const { if ( ! _fp ) /* replaying, don't bother */ - return; + log( "%s 0x%X create ", class_name(), _id ); Log_Entry e;