From 41b7c62c15d86881bad32dd52f0bfaefc4769a17 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 22 Feb 2020 13:19:43 +0000 Subject: [PATCH] Delay initialisation of global EDA_ITEMs. It causes issues with boost::uuid generation in some versions of boost. --- pcbnew/board_connected_item.cpp | 4 ++-- pcbnew/class_board.cpp | 9 ++++++--- pcbnew/netinfo.h | 10 +++++++++- pcbnew/netinfo_list.cpp | 1 - 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pcbnew/board_connected_item.cpp b/pcbnew/board_connected_item.cpp index e395e5b579..e4b089bfae 100644 --- a/pcbnew/board_connected_item.cpp +++ b/pcbnew/board_connected_item.cpp @@ -41,7 +41,7 @@ const wxChar* const traceMask = wxT( "BOARD_CONNECTED_ITEM" ); BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) : - BOARD_ITEM( aParent, idtype ), m_netinfo( &NETINFO_LIST::ORPHANED_ITEM ) + BOARD_ITEM( aParent, idtype ), m_netinfo( NETINFO_LIST::OrphanedItem() ) { m_localRatsnestVisible = true; } @@ -66,7 +66,7 @@ bool BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode, bool aNoAssert ) if( ( aNetCode >= 0 ) && board ) m_netinfo = board->FindNet( aNetCode ); else - m_netinfo = &NETINFO_LIST::ORPHANED_ITEM; + m_netinfo = NETINFO_LIST::OrphanedItem(); if( !aNoAssert ) wxASSERT( m_netinfo ); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 5755709cd7..966a3b670d 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -85,7 +85,7 @@ public: #endif }; -DELETED_BOARD_ITEM g_DeletedItem; +DELETED_BOARD_ITEM* g_DeletedItem = nullptr; /* This is an odd place for this, but CvPcb won't link if it is @@ -735,7 +735,10 @@ BOARD_ITEM* BOARD::GetItem( void* aWeakReference ) return drawing; // Not found; weak reference has been deleted. - return &g_DeletedItem; + if( !g_DeletedItem ) + g_DeletedItem = new DELETED_BOARD_ITEM(); + + return g_DeletedItem; } @@ -1042,7 +1045,7 @@ NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const wxASSERT( m_NetInfo.GetNetCount() > 0 ); if( aNetcode == NETINFO_LIST::UNCONNECTED && m_NetInfo.GetNetCount() == 0 ) - return &NETINFO_LIST::ORPHANED_ITEM; + return NETINFO_LIST::OrphanedItem(); else return m_NetInfo.GetNetItem( aNetcode ); } diff --git a/pcbnew/netinfo.h b/pcbnew/netinfo.h index 5cee12a128..263e03f88c 100644 --- a/pcbnew/netinfo.h +++ b/pcbnew/netinfo.h @@ -468,7 +468,15 @@ public: ///> NETINFO_ITEM meaning that there was no net assigned for an item, as there was no ///> board storing net list available. - static NETINFO_ITEM ORPHANED_ITEM; + static NETINFO_ITEM* OrphanedItem() + { + static NETINFO_ITEM* g_orphanedItem; + + if( !g_orphanedItem ) + g_orphanedItem = new NETINFO_ITEM( nullptr, wxEmptyString, NETINFO_LIST::UNCONNECTED ); + + return g_orphanedItem; + } #if defined(DEBUG) void Show() const; diff --git a/pcbnew/netinfo_list.cpp b/pcbnew/netinfo_list.cpp index 5f2d8cfa1a..a0170e412b 100644 --- a/pcbnew/netinfo_list.cpp +++ b/pcbnew/netinfo_list.cpp @@ -246,4 +246,3 @@ NETINFO_ITEM* NETINFO_MAPPING::iterator::operator->() const const int NETINFO_LIST::UNCONNECTED = 0; const int NETINFO_LIST::ORPHANED = -1; -NETINFO_ITEM NETINFO_LIST::ORPHANED_ITEM = NETINFO_ITEM( NULL, wxEmptyString, NETINFO_LIST::UNCONNECTED );