Tango: fixed second database not saved when hitting Save two times consecutively

This commit is contained in:
matlabbe
2016-11-21 18:13:56 -05:00
parent 1c41882bf0
commit 3d5699ef4a
3 changed files with 11 additions and 7 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
<!-- BEGIN_INCLUDE(manifest) --> <!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.introlab.rtabmap" package="com.introlab.rtabmap"
android:versionCode="21" android:versionCode="22"
android:versionName="@RTABMAP_VERSION@"> android:versionName="@RTABMAP_VERSION@">
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
@@ -1082,14 +1082,13 @@ public class RTABMapActivity extends Activity implements OnClickListener {
notificationManager.notify(0, n); notificationManager.notify(0, n);
} }
mOpenedDatabasePath = newDatabasePath;
mProgressDialog.dismiss(); mProgressDialog.dismiss();
} }
}); });
} }
}); });
saveThread.start(); saveThread.start();
mOpenedDatabasePath = newDatabasePath;
} }
}) })
.setNegativeButton("No", new DialogInterface.OnClickListener() { .setNegativeButton("No", new DialogInterface.OnClickListener() {
@@ -1145,14 +1144,13 @@ public class RTABMapActivity extends Activity implements OnClickListener {
notificationManager.notify(0, n); notificationManager.notify(0, n);
} }
mOpenedDatabasePath = newDatabasePath;
mProgressDialog.dismiss(); mProgressDialog.dismiss();
} }
}); });
} }
}); });
saveThread.start(); saveThread.start();
mOpenedDatabasePath = newDatabasePath;
} }
} }
} }
+8 -2
View File
@@ -309,7 +309,13 @@ void Memory::close(bool databaseSaved, bool postInitClosingEvents, const std::st
UINFO("databaseSaved=%d, postInitClosingEvents=%d", databaseSaved?1:0, postInitClosingEvents?1:0); UINFO("databaseSaved=%d, postInitClosingEvents=%d", databaseSaved?1:0, postInitClosingEvents?1:0);
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(RtabmapEventInit::kClosing)); if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(RtabmapEventInit::kClosing));
if(!databaseSaved || (!_memoryChanged && !_linksChanged)) bool databaseNameChanged = false;
if(databaseSaved)
{
databaseNameChanged = ouputDatabasePath.size() && _dbDriver->getUrl().size() && _dbDriver->getUrl().compare(ouputDatabasePath) != 0?true:false;
}
if(!databaseSaved || (!_memoryChanged && !_linksChanged && !databaseNameChanged))
{ {
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(uFormat("No changes added to database."))); if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(uFormat("No changes added to database.")));
@@ -317,7 +323,7 @@ void Memory::close(bool databaseSaved, bool postInitClosingEvents, const std::st
if(_dbDriver) if(_dbDriver)
{ {
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(uFormat("Closing database \"%s\"...", _dbDriver->getUrl().c_str()))); if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(uFormat("Closing database \"%s\"...", _dbDriver->getUrl().c_str())));
_dbDriver->closeConnection(false); _dbDriver->closeConnection(false, ouputDatabasePath);
delete _dbDriver; delete _dbDriver;
_dbDriver = 0; _dbDriver = 0;
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit("Closing database, done!")); if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit("Closing database, done!"));