mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-07 18:47:48 +08:00
Fix possible staled flann index (#1742)
* Fix possible staled flann index * fixed compatible crc flann index after repair and reload * Added tests * test coverage * testing another possible branch * removed doxygen tag version not opulated yet * updated codedev to ignore test code * Disabled all mac intel ci flaky builds
This commit is contained in:
+20
-4
@@ -614,7 +614,12 @@ void Memory::loadDataFromDb(bool postInitClosingEvents)
|
||||
UWARN("%s", msg.c_str());
|
||||
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(msg));
|
||||
_memoryChanged = true; // This will force rtabmap to save back the dictionary even if we don't process any new data
|
||||
_vwd->update();
|
||||
// Re-index from scratch instead of adding the words above to the
|
||||
// index already built: the index would then contain them in a
|
||||
// different order than the words loaded from the database, which
|
||||
// makes the index saved on close (see saveFlannIndex()) rejected
|
||||
// when it is deserialized on next load.
|
||||
_vwd->rebuildIndex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,12 +719,21 @@ void Memory::close(bool databaseSaved, bool postInitClosingEvents, const std::st
|
||||
UINFO("No changes added to database.");
|
||||
if(_dbDriver)
|
||||
{
|
||||
if(!this->isReadOnly()) {
|
||||
if(this->isReadOnly())
|
||||
{
|
||||
if(_memoryChanged || _linksChanged || databaseNameChanged)
|
||||
{
|
||||
UWARN("Memory has been modified (nodes=%s links=%s name=%s) but the database is read-only, changes are not saved to database.",
|
||||
_memoryChanged?"true":"false", _linksChanged?"true":"false", databaseNameChanged?"true":"false");
|
||||
}
|
||||
}
|
||||
else if(databaseSaved)
|
||||
{
|
||||
saveFlannIndex(postInitClosingEvents);
|
||||
}
|
||||
else if(_memoryChanged || _linksChanged || databaseNameChanged)
|
||||
{
|
||||
UWARN("Memory has been modified (nodes=%s links=%s name=%s) but the database is read-only, changes are not saved to database.",
|
||||
UWARN("Memory has been modified (nodes=%s links=%s name=%s) but databaseSaved=false, changes are not saved to database.",
|
||||
_memoryChanged?"true":"false", _linksChanged?"true":"false", databaseNameChanged?"true":"false");
|
||||
}
|
||||
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(uFormat("Closing database \"%s\"...", _dbDriver->getUrl().c_str())));
|
||||
@@ -736,8 +750,10 @@ void Memory::close(bool databaseSaved, bool postInitClosingEvents, const std::st
|
||||
{
|
||||
UINFO("Saving memory...");
|
||||
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit("Saving memory..."));
|
||||
if(!_memoryChanged && _dbDriver)
|
||||
if(_dbDriver)
|
||||
{
|
||||
// Must be done before clear(), which clears the dictionary.
|
||||
// saveFlannIndex() saves only if the dictionary has been modified.
|
||||
saveFlannIndex(postInitClosingEvents);
|
||||
}
|
||||
this->clear();
|
||||
|
||||
Reference in New Issue
Block a user