← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH]fix library cache issue

 

I have made another try.

This time as the library timestamp is always use as library identifier, I
add it with hash of the library name. The internal variable of the
GenerateTimestamp function was already called "hash", so I guess it was the
idea at first time.
I didn't find any good hash function on the kicad source code
except wxHashTable::MakeKey. The function sums all character to make an
hash so library "ba" and library "ab" with have the same output. But at
least it will prevent the bug 99% of the time.



Damien

2018-06-08 23:43 GMT+02:00 Damien Espitallier <damien.espitallier@xxxxxxxxx>
:

> Thanks for your feedbacks, i will try to improve the patch
>
> Le ven. 8 juin 2018 22:29, Seth Hillbrand <seth.hillbrand@xxxxxxxxx> a
> écrit :
>
>>
>> ​Hi Damien-
>>
>> ​Library name is frequently NULL.  This will segfault in your
>> implementation.
>>
>> -S
>>
>>
>> Am Fr., 8. Juni 2018 um 13:04 Uhr schrieb Damien Espitallier <
>> damien.espitallier@xxxxxxxxx>:
>>
>>> 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
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~kicad-developers
>>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~kicad-developers
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>
From 42dc4d907f81b4ea9382d64933d6232a666f2c62 Mon Sep 17 00:00:00 2001
From: Damien Espitallier <damien.espitallier@xxxxxxxxx>
Date: Sat, 9 Jun 2018 10:20:41 +0200
Subject: [PATCH] Add library name pseudo-hash in fp_list_table
 GenerateTimestamp output
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

---
 common/fp_lib_table.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


--------------2.17.1
Content-Type: text/x-patch; name="0001-Add-library-name-pseudo-hash-in-fp_list_table-Genera.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Add-library-name-pseudo-hash-in-fp_list_table-Genera.patch"

diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp
index 46a9e8e1f..9aa049dd7 100644
--- a/common/fp_lib_table.cpp
+++ b/common/fp_lib_table.cpp
@@ -241,7 +241,7 @@ long long FP_LIB_TABLE::GenerateTimestamp( const wxString* aNickname )
     {
         const FP_LIB_TABLE_ROW* row = FindRow( *aNickname );
         wxASSERT( (PLUGIN*) row->plugin );
-        return row->plugin->GetLibraryTimestamp( row->GetFullURI( true ) );
+        return row->plugin->GetLibraryTimestamp( row->GetFullURI( true ) ) + wxHashTable::MakeKey( *aNickname );
     }
 
     long long hash = 0;
@@ -249,7 +249,7 @@ long long FP_LIB_TABLE::GenerateTimestamp( const wxString* aNickname )
     {
         const FP_LIB_TABLE_ROW* row = FindRow( nickname );
         wxASSERT( (PLUGIN*) row->plugin );
-        hash += row->plugin->GetLibraryTimestamp( row->GetFullURI( true ) );
+        hash += row->plugin->GetLibraryTimestamp( row->GetFullURI( true ) ) + wxHashTable::MakeKey( nickname );
     }
 
     return hash;

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



Follow ups

References