Better fix for bugs 1703258 and 1702707: better detection of cache lib modifications, not always detected previously.

The component to symbol links were previously not always updated after a library change,
if the change is made outside the library editor.
This commit is contained in:
jean-pierre charras 2017-07-12 11:55:51 +02:00
parent 08c4a0bc7b
commit 459fd9e584
5 changed files with 18 additions and 18 deletions

View File

@ -472,6 +472,11 @@ int PART_LIBS::GetModifyHash()
hash += it->GetModHash();
}
// Rebuilding the cache (m_cache) does not change the GetModHash() value,
// but changes PART_LIBS::s_modify_generation.
// Take this change in account:
hash += PART_LIBS::s_modify_generation;
return hash;
}

View File

@ -344,13 +344,6 @@ public:
*/
int GetModHash() const { return m_mod_hash; }
/**
* Forces a change of the magic number that usually changes
* if the library has changed. Usefull to force initializations
* only made on library change.
*/
void IncModHash() { ++m_mod_hash; }
SCH_IO_MGR::SCH_FILE_T GetPluginType() const { return m_pluginType; }
void SetPluginType( SCH_IO_MGR::SCH_FILE_T aPluginType );

View File

@ -54,13 +54,6 @@ bool SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile( bool aUseCurrentSheetFilenam
bool success = CreateArchiveLibrary( fn.GetFullPath() );
// Mark the library cache as modified:
PART_LIBS* libs = Prj().SchLibs();
PART_LIB* libcache = libs->FindLibrary( fn.GetName() );
if( libcache )
libcache->IncModHash();
// Update the schematic symbol library links.
// because the lib cache has changed
SCH_SCREENS schematic;

View File

@ -3387,6 +3387,11 @@ void SCH_LEGACY_PLUGIN::cacheLib( const wxString& aLibraryFileName )
delete m_cache;
m_cache = new SCH_LEGACY_PLUGIN_CACHE( aLibraryFileName );
// Because m_cache is rebuilt, increment PART_LIBS::s_modify_generation
// to modify the hash value that indicate component to symbol links
// must be updated.
PART_LIBS::s_modify_generation++;
if( !isBuffering( m_props ) )
m_cache->Load();
}

View File

@ -562,15 +562,16 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode
* their SCH_SCREEN::Draw() draws nothing
*/
// Ensure links are up to date, even if a library was reloaded for some reason:
CheckComponentsToPartsLinks();
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
if( item->IsMoving() || item->IsResized() )
continue;
// uncomment line below when there is a virtual
// EDA_ITEM::GetBoundingBox()
// if( panel->GetClipBox().Intersects( Structs->GetBoundingBox()
// ) )
// uncomment line below when there is a virtual EDA_ITEM::GetBoundingBox()
// if( panel->GetClipBox().Intersects( item->GetBoundingBox() ) )
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
}
}
@ -582,6 +583,9 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode
*/
void SCH_SCREEN::Plot( PLOTTER* aPlotter )
{
// Ensure links are up to date, even if a library was reloaded for some reason:
CheckComponentsToPartsLinks();
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
aPlotter->SetCurrentLineWidth( item->GetPenSize() );