Mainform.SessionName is used for write operations to registry. If you

a) connect a session
b) open the session manager
c) rename the current session
... your registry has a nearly empty session folder, after DoDisconnect() stores the last active database with the old session name.
This change fixes the SessionName variable and window caption immediately after a session was renamed.
This commit is contained in:
Ansgar Becker
2009-08-18 19:35:47 +00:00
parent 4d7a301b78
commit 4bf22d785e
2 changed files with 28 additions and 17 deletions

View File

@ -473,6 +473,11 @@ begin
SessionKey := REGPATH + REGKEY_SESSIONS + SelectedSession;
if MainReg.KeyExists(SessionKey) then
MainReg.MoveKey(SessionKey, REGPATH + REGKEY_SESSIONS + NewText, true);
// Also fix internal session name in main form, which gets used to store e.g. "lastuseddb" later
if Mainform.SessionName = SelectedSession then begin
Mainform.SessionName := NewText;
Mainform.SetWindowCaption;
end;
FSessionNames[FSessionNames.IndexOf(SelectedSession)] := NewText;
RefreshSessionList(False);
end;

View File

@ -722,7 +722,6 @@ type
dsHaveEngines,
dsCollations : TDataset;
FilterPanelManuallyOpened : Boolean;
winName : String;
FSelectedTableColumns,
FSelectedTableKeys : TDataset;
DataGridDB, DataGridTable : WideString;
@ -770,6 +769,7 @@ type
dataselected : Boolean;
editing : Boolean;
mysql_version : Integer;
WindowNumber : Integer;
SessionName : String;
VTRowDataListVariables,
VTRowDataListStatus,
@ -875,6 +875,7 @@ type
function GetCollations(Items: TWideStrings = nil): TDataset;
procedure SetEditorTabCaption(Editor: TFrame; ObjName: WideString);
procedure ResetSelectedTableStuff;
procedure SetWindowCaption;
end;
@ -1660,12 +1661,7 @@ begin
// Define window properties
SetWindowConnected( true );
i := SetWindowName( SessionName );
winName := SessionName;
if ( i <> 0 ) then
begin
winName := winName + Format( ' (%d)', [i] );
end;
WindowNumber := SetWindowName(SessionName);
// Reselect last used database
if GetRegValue( REGNAME_RESTORELASTUSEDDB, DEFAULT_RESTORELASTUSEDDB ) then begin
@ -6867,7 +6863,7 @@ end;
procedure TMainForm.DBtreeFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
var
newDb, newDbObject, Cap: WideString;
newDb, newDbObject: WideString;
begin
debug('DBtreeFocusChanged()');
if not Assigned(Node) then
@ -6911,15 +6907,7 @@ begin
if newDb <> '' then
LoadDatabaseProperties(newDb);
FixQueryTabCloseButtons;
// Set window caption and taskbar text
Cap := winName;
if newDb <> '' then
Cap := Cap + ' /' + newDb;
if newDbObject <> '' then
Cap := Cap + '/' + newDbObject;
Cap := Cap + ' - ' + APPNAME + ' ' + FullAppVersion;
Caption := Cap;
Application.Title := Cap;
SetWindowCaption;
end;
@ -9433,5 +9421,23 @@ begin
Result := PageIndex >= Min;
end;
procedure TMainForm.SetWindowCaption;
var
Cap: String;
begin
// Set window caption and taskbar text
Cap := SessionName;
if WindowNumber <> 0 then
Cap := Cap + Format( ' (%d)', [WindowNumber] );
if ActiveDatabase <> '' then
Cap := Cap + ' /' + ActiveDatabase;
if SelectedTable.Text <> '' then
Cap := Cap + '/' + SelectedTable.Text;
Cap := Cap + ' - ' + APPNAME + ' ' + FullAppVersion;
Caption := Cap;
Application.Title := Cap;
end;
end.