← Back to team overview

kicad-developers team mailing list archive

[PATCH]fix library cache issue

 

Hi,

I found a bug with the library browser.

Step to reproduce:
 - open Kicad
 - open PCBNew
 - click on Load footprint from library
 - click on select by browser
 - select a library then quickly change to an another one

=> bug: the second category is selected but footprint list if for the first
one.
=> bug2: selecting a footprint cause an assert: "/home/damien/prog/kicad-
source-mirror/pcbnew/class_board.cpp(838): assert "Assert failure" failed
in Add(): BOARD::Add() param error: aBoardItem NULL"


The attached patch fix the issue by checking the library name in addition
to the library timestamp.

Damien Espitallier
From 01959280e84c6b8106da02ce9408873ae70c580c Mon Sep 17 00:00:00 2001
From: Damien Espitallier <damien.espitallier@xxxxxxxxx>
Date: Fri, 8 Jun 2018 07:06:34 +0200
Subject: [PATCH] Do not use only timestamp when choosing to reload or not the
 library
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.17.1"

This is a multi-part message in MIME format.
--------------2.17.1
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 pcbnew/footprint_info_impl.cpp | 10 ++++++----
 pcbnew/footprint_info_impl.h   |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)


--------------2.17.1
Content-Type: text/x-patch; name="0001-Do-not-use-only-timestamp-when-choosing-to-reload-or.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Do-not-use-only-timestamp-when-choosing-to-reload-or.patch"

diff --git a/pcbnew/footprint_info_impl.cpp b/pcbnew/footprint_info_impl.cpp
index 4d9abff17..1794681c7 100644
--- a/pcbnew/footprint_info_impl.cpp
+++ b/pcbnew/footprint_info_impl.cpp
@@ -119,8 +119,10 @@ void FOOTPRINT_LIST_IMPL::loader_job()
 bool FOOTPRINT_LIST_IMPL::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname,
                                               PROGRESS_REPORTER* aProgressReporter )
 {
-    if( m_list_timestamp == aTable->GenerateTimestamp( aNickname ) )
+    if( ( m_list_timestamp ==  aTable->GenerateTimestamp( aNickname ) ) && ( *aNickname == m_library ) )
+    {
         return true;
+    }
 
     m_progress_reporter = aProgressReporter;
     m_cancelled = false;
@@ -172,7 +174,7 @@ void FOOTPRINT_LIST_IMPL::StartWorkers( FP_LIB_TABLE* aTable, wxString const* aN
 {
     m_loader = aLoader;
     m_lib_table = aTable;
-    m_library = aNickname;
+    m_library = *aNickname;
 
     // Clear data before reading files
     m_count_finished.store( 0 );
@@ -314,7 +316,7 @@ bool FOOTPRINT_LIST_IMPL::JoinWorkers()
     if( m_cancelled )
         m_list_timestamp = 0;       // God knows what we got before we were cancelled
     else
-        m_list_timestamp = m_lib_table->GenerateTimestamp( m_library );
+        m_list_timestamp = m_lib_table->GenerateTimestamp( &m_library );
 
     return m_errors.empty();
 }
@@ -322,12 +324,12 @@ bool FOOTPRINT_LIST_IMPL::JoinWorkers()
 
 FOOTPRINT_LIST_IMPL::FOOTPRINT_LIST_IMPL() :
     m_loader( nullptr ),
-    m_library( nullptr ),
     m_count_finished( 0 ),
     m_list_timestamp( 0 ),
     m_progress_reporter( nullptr ),
     m_cancelled( false )
 {
+  m_library.clear();
 }
 
 
diff --git a/pcbnew/footprint_info_impl.h b/pcbnew/footprint_info_impl.h
index 5af8c34a2..4ca936e54 100644
--- a/pcbnew/footprint_info_impl.h
+++ b/pcbnew/footprint_info_impl.h
@@ -57,7 +57,7 @@ protected:
 class FOOTPRINT_LIST_IMPL : public FOOTPRINT_LIST
 {
     FOOTPRINT_ASYNC_LOADER*  m_loader;
-    const wxString*          m_library;
+    wxString                 m_library;
     std::vector<std::thread> m_threads;
     SYNC_QUEUE<wxString>     m_queue_in;
     SYNC_QUEUE<wxString>     m_queue_out;

--------------2.17.1--



Follow ups