router: LOGGER now stores UUIDs, not pointers to BOARD_ITEMs.

Caused occasional crashes when saving the debug event log, as some of the BOARD_ITEMS could have been deleted before SaveLog call.
This commit is contained in:
Tomasz Wlostowski 2021-06-03 22:32:20 +02:00
parent e5e588ebba
commit 3e98c44636
3 changed files with 8 additions and 13 deletions

View File

@ -53,11 +53,7 @@ void LOGGER::Save( const std::string& aFilename )
{
uint64_t id = 0;
if( evt.item && evt.item->Parent() )
{
const char* idString = evt.item->Parent()->m_Uuid.AsString().c_str();
fprintf( f, "event %d %d %d %s\n", evt.type, evt.p.x, evt.p.y, idString );
}
fprintf( f, "event %d %d %d %s\n", evt.type, evt.p.x, evt.p.y, (const char *) evt.uuid );
}
fclose( f );
@ -70,10 +66,13 @@ void LOGGER::Log( LOGGER::EVENT_TYPE evt, VECTOR2I pos, const ITEM* item )
ent.type = evt;
ent.p = pos;
ent.item = item;
ent.uuid = "null";
if( item && item->Parent() )
ent.uuid = item->Parent()->m_Uuid.AsString();
m_events.push_back( ent );
}
}

View File

@ -51,7 +51,7 @@ public:
struct EVENT_ENTRY {
VECTOR2I p;
EVENT_TYPE type;
const ITEM* item;
wxString uuid;
};
LOGGER();

View File

@ -531,12 +531,8 @@ void ROUTER_TOOL::saveRouterDebugLog()
for( auto evt : events)
{
wxString id = "null";
if( evt.item && evt.item->Parent() )
id = evt.item->Parent()->m_Uuid.AsString();
fprintf( f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type,
(const char*) id.c_str() );
(const char*) evt.uuid );
}
fclose( f );