diff --git a/source/connections.pas b/source/connections.pas index 3d0c12c5..499445c0 100644 --- a/source/connections.pas +++ b/source/connections.pas @@ -112,10 +112,10 @@ begin EditOnlyDBs.Text, EditTimeout.Text, IntToStr(Integer(CheckBoxCompressed.Checked)), - IntToStr(Integer(CheckboxSorted.Checked)), - ComboboxDescription.Text) then - ModalResult := mrOK - else begin + IntToStr(Integer(CheckboxSorted.Checked))) then begin + ModalResult := mrOK; + Mainform.SessionName := ComboBoxDescription.Text; + end else begin ModalResult := mrNone; btn.Enabled := True; end; diff --git a/source/exportsql.pas b/source/exportsql.pas index 1533a9d4..0d52e914 100644 --- a/source/exportsql.pas +++ b/source/exportsql.pas @@ -194,7 +194,7 @@ begin // read dbs and Tables from treeview comboSelectDatabase.Items.Clear; - Caption := Mainform.MysqlConn.SessionName + ' - Export Tables...'; + Caption := Mainform.SessionName + ' - Export Tables...'; comboSelectDatabase.Items.Assign(Mainform.Databases); comboSelectDatabase.ItemIndex := comboSelectDatabase.Items.IndexOf(Mainform.ActiveDatabase); // Select first database if at least one is available. diff --git a/source/insertfiles.pas b/source/insertfiles.pas index 700ce125..0d9c8b08 100644 --- a/source/insertfiles.pas +++ b/source/insertfiles.pas @@ -92,7 +92,7 @@ end; { FormShow } procedure TfrmInsertFiles.FormShow(Sender: TObject); begin - Caption := Mainform.MysqlConn.SessionName + ' - Insert files into table ...'; + Caption := Mainform.SessionName + ' - Insert files into table ...'; ComboBoxDBs.Items.Clear; ComboBoxDBs.Items.Assign(Mainform.Databases); ComboBoxDBs.ItemIndex := ComboBoxDBs.Items.IndexOf( Mainform.ActiveDatabase ); diff --git a/source/main.pas b/source/main.pas index f532c58c..1db5ac4e 100644 --- a/source/main.pas +++ b/source/main.pas @@ -846,7 +846,7 @@ type procedure popupQueryLoadClick( sender: TObject ); procedure FillPopupQueryLoad; procedure PopupQueryLoadRemoveAbsentFiles( sender: TObject ); - function InitConnection(parHost, parPort, parUser, parPass, parDatabase, parTimeout, parCompress, parSortDatabases, parDescription: WideString): Boolean; + function InitConnection(parHost, parPort, parUser, parPass, parDatabase, parTimeout, parCompress, parSortDatabases: WideString): Boolean; //procedure HandleQueryNotification(ASender : TMysqlQuery; AEvent : Integer); function GetVisualDataset: PGridResult; @@ -1205,7 +1205,7 @@ begin // Open server-specific registry-folder. // relative from already opened folder! - OpenRegistry(FConn.Description); + OpenRegistry(SessionName); MainReg.WriteString( REGNAME_LASTUSEDDB, Utf8Encode(ActiveDatabase) ); // Clear database and table lists @@ -1421,7 +1421,6 @@ begin pnlQueryMemo.Height := GetRegValue(REGNAME_QUERYMEMOHEIGHT, pnlQueryMemo.Height); pnlQueryHelpers.Width := GetRegValue(REGNAME_QUERYHELPERSWIDTH, pnlQueryHelpers.Width); DBtree.Width := GetRegValue(REGNAME_DBTREEWIDTH, DBtree.Width); - DBTree.Color := GetRegValue(REGNAME_TREEBACKGROUND, clWindow, FConn.Description); SynMemoSQLLog.Height := GetRegValue(REGNAME_SQLOUTHEIGHT, SynMemoSQLLog.Height); prefMaxColWidth := GetRegValue(REGNAME_MAXCOLWIDTH, DEFAULT_MAXCOLWIDTH); // Fix registry entry from older versions which can have 0 here which makes no sense @@ -1590,8 +1589,9 @@ begin // Parameters belong to connection, not to a SQL file which should get opened loadsqlfile := False; // Take care for empty description - it gets used to read/write session settings to registry! - if parDescription = '' then - parDescription := parHost; + SessionName := parDescription; + if SessionName = '' then + SessionName := parHost; if InitConnection( parHost, parPort, @@ -1600,8 +1600,7 @@ begin parDatabase, parTimeout, parCompress, - parSortDatabases, - parDescription) then + parSortDatabases) then begin // Save session parameters to registry if MainReg.OpenKey(REGPATH + REGKEY_SESSIONS + parDescription, true) then @@ -1645,11 +1644,12 @@ begin ActivateFileLogging; Delimiter := GetRegValue(REGNAME_DELIMITER, DEFAULT_DELIMITER); - SessionName := FMysqlConn.SessionName; DatabasesWanted := explode(';', FConn.DatabaseList); if FConn.DatabaseListSort then DatabasesWanted.Sort; + DBTree.Color := GetRegValue(REGNAME_TREEBACKGROUND, clWindow, SessionName); + // Fill variables-list, processlist and DB-tree ShowVariablesAndProcesses( Self ); // Invoke population of database tree. It's important to do this here after @@ -1701,7 +1701,7 @@ begin if DatabasesWanted.Count > 0 then begin DatabasesWanted.Add( newdb ); - OpenRegistry(Conn.Description); + OpenRegistry(SessionName); MainReg.WriteString( 'OnlyDBs', ImplodeStr( ';', DatabasesWanted ) ); end; // reload db nodes and switch to new one @@ -2308,7 +2308,7 @@ end; Receive connection parameters and create the mdi-window Paremeters are either sent by connection-form or by commandline. } -function TMainform.InitConnection(parHost, parPort, parUser, parPass, parDatabase, parTimeout, parCompress, parSortDatabases, parDescription: WideString): Boolean; +function TMainform.InitConnection(parHost, parPort, parUser, parPass, parDatabase, parTimeout, parCompress, parSortDatabases: WideString): Boolean; var AutoReconnect: Boolean; begin @@ -2337,7 +2337,6 @@ begin DatabaseList := parDatabase; DatabaseListSort := Boolean(StrToIntDef(parSortDatabases, 0)); - Description := parDescription; end; FMysqlConn := TMysqlConn.Create(@FConn); @@ -2573,7 +2572,7 @@ begin ClearDbTableList(db); if DatabasesWanted.IndexOf(db) > -1 then begin DatabasesWanted.Delete( DatabasesWanted.IndexOf(db) ); - OpenRegistry(Conn.Description); + OpenRegistry(SessionName); MainReg.WriteString( 'OnlyDBs', ImplodeStr( ';', DatabasesWanted ) ); end; DBtree.Selected[DBtree.GetFirst] := true; @@ -6708,11 +6707,11 @@ begin begin LogfilePattern := '%s %.6u.log'; i := 1; - FileNameSessionLog := DirnameSessionLogs + goodfilename(Format(LogfilePattern, [FConn.Description, i])); + FileNameSessionLog := DirnameSessionLogs + goodfilename(Format(LogfilePattern, [SessionName, i])); while FileExists( FileNameSessionLog ) do begin inc(i); - FileNameSessionLog := DirnameSessionLogs + goodfilename(Format(LogfilePattern, [FConn.Description, i])); + FileNameSessionLog := DirnameSessionLogs + goodfilename(Format(LogfilePattern, [SessionName, i])); end; end; @@ -7631,7 +7630,7 @@ begin query := query + WideFormat(' LIMIT %d, %d', [start, limit]); // Set indicator for possibly crashing query - OpenRegistry(FConn.Description); + OpenRegistry(SessionName); regCrashIndicName := Utf8Encode(REGPREFIX_CRASH_IN_DATA + ActiveDatabase + '.' + SelectedTable); MainReg.WriteBool(regCrashIndicName, True); diff --git a/source/mysqlconn.pas b/source/mysqlconn.pas index bd41af97..f117b392 100644 --- a/source/mysqlconn.pas +++ b/source/mysqlconn.pas @@ -17,7 +17,6 @@ type FConn : TZConnection; FOpenConn : TOpenConnProf; FLastError : String; - function GetSessionName: String; function GetIsAlive: Boolean; function GetIsConnected: Boolean; //FTimer : TTimer; @@ -30,7 +29,6 @@ type property IsAlive : Boolean read GetIsAlive; property Connection : TZConnection read FConn; property LastError : String read FLastError; - property SessionName : String read GetSessionName; end; implementation @@ -96,11 +94,6 @@ begin inherited; end; -function TMysqlConn.GetSessionName: String; -begin - result := FOpenConn.Description; -end; - function TMysqlConn.GetIsAlive: Boolean; begin Result := False; diff --git a/source/mysqlquerythread.pas b/source/mysqlquerythread.pas index 3a2105e8..f54c77e3 100644 --- a/source/mysqlquerythread.pas +++ b/source/mysqlquerythread.pas @@ -42,7 +42,6 @@ type MysqlParams : TMysqlConnParams; // stuff that needs to be shipped over to the mysql driver. DatabaseList : WideString; DatabaseListSort : Boolean; - Description : String; MysqlConn : TZConnection; end; POpenConnProf = ^TOpenConnProf;