From 3e98c44636fa564084cc0ffdc404192734bbe2a4 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Thu, 3 Jun 2021 22:32:20 +0200 Subject: [PATCH] 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. --- pcbnew/router/pns_logger.cpp | 13 ++++++------- pcbnew/router/pns_logger.h | 2 +- pcbnew/router/router_tool.cpp | 6 +----- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/pcbnew/router/pns_logger.cpp b/pcbnew/router/pns_logger.cpp index b341ac55fe..c17dd58331 100644 --- a/pcbnew/router/pns_logger.cpp +++ b/pcbnew/router/pns_logger.cpp @@ -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 ); - } } diff --git a/pcbnew/router/pns_logger.h b/pcbnew/router/pns_logger.h index 7a7a64c9af..f65ec4daf2 100644 --- a/pcbnew/router/pns_logger.h +++ b/pcbnew/router/pns_logger.h @@ -51,7 +51,7 @@ public: struct EVENT_ENTRY { VECTOR2I p; EVENT_TYPE type; - const ITEM* item; + wxString uuid; }; LOGGER(); diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 760a4d45a6..e4f0dfcf47 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -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 );