Browse Source

fix memory index restore

CPP-GTK4
yggverse 2 months ago
parent
commit
5c19a2cda9
  1. 19
      src/app/browser/main/tab/page/navigation/history.cpp

19
src/app/browser/main/tab/page/navigation/history.cpp

@ -67,7 +67,7 @@ int History::restore(
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab_page_navigation_history__session` SELECT * FROM `app_browser_main_tab_page_navigation_history__session`
WHERE `app_browser_main_tab_page_navigation__session__id` = %d WHERE `app_browser_main_tab_page_navigation__session__id` = %d
ORDER BY `id` DESC LIMIT 1 ORDER BY `id` DESC
)SQL", )SQL",
APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION__ID
).c_str(), ).c_str(),
@ -79,12 +79,15 @@ int History::restore(
if (PREPARE_STATUS == SQLITE_OK) if (PREPARE_STATUS == SQLITE_OK)
{ {
// Use latest record as order // Reset current memory index
while (sqlite3_step(statement) == SQLITE_ROW) index = -1;
{
// Cleanup // Cleanup memory vector
memory.clear(); memory.clear();
// Restore memory from database records
while (sqlite3_step(statement) == SQLITE_ROW)
{
// Restore // Restore
memory.push_back( memory.push_back(
{ {
@ -108,6 +111,12 @@ int History::restore(
// Restore children components here (on available) // Restore children components here (on available)
} }
// Navigate to latest memory index on current value still not found in database
if (index == -1)
{
index = memory.size() - 1;
}
} }
return sqlite3_finalize( return sqlite3_finalize(

Loading…
Cancel
Save