From 12606e7de3cfde789c9f0a6a040136dbb8c1917c Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sat, 11 Apr 2020 13:34:17 +0200 Subject: [PATCH] Store last used database directly, not only when closing a session. Closes #983 --- source/dbconnection.pas | 7 +++++++ source/main.pas | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 14c7f790..2a54f4b7 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -3555,6 +3555,13 @@ begin Query(GetSQLSpecifity(spUSEQuery, [s]), False); // FDatabase is set via DetectUSEQuery end; + + // Save last used database in session, see #983 + if not FParameters.SessionName.IsEmpty then begin + AppSettings.SessionPath := FParameters.SessionPath; + AppSettings.WriteString(asLastUsedDB, Value); + end; + if Assigned(FOnObjectnamesChanged) then FOnObjectnamesChanged(Self, FDatabase); end; diff --git a/source/main.pas b/source/main.pas index fb9b6886..15d74222 100644 --- a/source/main.pas +++ b/source/main.pas @@ -2457,8 +2457,6 @@ begin RefreshHelperNode(HELPERNODE_COLUMNS); // Last chance to access connection related properties before disconnecting - AppSettings.SessionPath := Item.Parameters.SessionPath; - AppSettings.WriteString(asLastUsedDB, Item.Database); // Disconnect Item.Active := False;