* Bugfix: plug the most obvious memory leaks.

* Clear some unused code and wrong comments.
This commit is contained in:
rosenfield
2007-11-09 09:51:31 +00:00
parent 51c23000f9
commit e7bcbdf293
23 changed files with 204 additions and 56 deletions

View File

@@ -1126,15 +1126,33 @@ procedure TMDIChild.FormClose(Sender: TObject; var Action: TCloseAction);
var
ws : String;
reg : TRegistry;
ds : TDataSet;
begin
SetWindowConnected( false );
SetWindowName( main.discname );
Application.Title := APPNAME;
ds := DataSource1.DataSet;
DataSource1.DataSet := nil;
if ds <> nil then ds.Close;
FreeAndNil(ds);
ds := DataSource2.DataSet;
DataSource2.DataSet := nil;
if ds <> nil then ds.Close;
FreeAndNil(ds);
ClearAllTableLists;
FreeAndNil(CachedTableLists);
FreeAndNil(methodStack);
// Closing connection
FMysqlConn.Disconnect;
FreeAndNil(FMysqlConn);
EnterCriticalSection(SqlMessagesLock);
FreeAndNil(SqlMessages);
LeaveCriticalSection(SqlMessagesLock);
// Closing connection and saving some vars into registry
// Saving some vars into registry
case ( WindowState ) of
wsNormal :
begin
@@ -1332,6 +1350,8 @@ begin
else OnlyDBs2.Add( dbName );
ds.Next();
end;
ds.Close;
FreeAndNil(ds);
OnlyDBs2.Sort();
// Prioritised position of system-databases
for i := ( specialDbs.Count - 1 ) downto 0 do begin
@@ -1543,9 +1563,9 @@ var
RewriteOrderClause : Boolean;
begin
viewingdata := true;
reg := TRegistry.Create();
sl_query := TStringList.Create();
try
sl_query := TStringList.Create();
// limit number of rows automatically if first time this table is shown
if ( not dataselected ) then begin
manualLimit := false;
@@ -1557,6 +1577,7 @@ begin
if Valueexists('DataLimit') then manualLimit := ReadBool('DataLimit');
end;
end;
Free;
end;
// limit number of rows fetched according to preferences
@@ -1590,7 +1611,6 @@ begin
EDBImage1.DataField := '';
EDBImage1.DataSource := DataSource1;
reg := TRegistry.Create();
reg.OpenKey( REGPATH + '\Servers\' + FConn.Description, true );
if not dataselected and prefRememberFilters then
@@ -1745,6 +1765,7 @@ begin
// free previous resultset
tmp := DataSource1.DataSet;
DataSource1.DataSet := nil;
if tmp <> nil then tmp.Close;
FreeAndNil(tmp);
// start query (with wait dialog)
@@ -1851,8 +1872,9 @@ begin
end;
Screen.Cursor := crDefault;
FreeAndNil (sl_query);
finally
FreeAndNil(reg);
FreeAndNil(sl_query);
viewingdata := false;
end;
end;
@@ -2082,11 +2104,12 @@ end;
procedure TMDIChild.ClearAllTableLists;
var
idx: Integer;
o: TObject;
ds: TDataSet;
begin
for idx := 0 to CachedTableLists.Count - 1 do begin
o := CachedTableLists.Objects[idx];
FreeAndNil(o);
ds := TDataSet(CachedTableLists.Objects[idx]);
ds.Close;
FreeAndNil(ds);
end;
CachedTableLists.Clear;
end;
@@ -2389,6 +2412,8 @@ begin
end;
end;
*}
ds.Close;
FreeAndNil(ds);
Screen.Cursor := crHourglass;
ds := GetResults( 'SHOW KEYS FROM ' + mask(table) );
@@ -2428,6 +2453,8 @@ begin
end;
ds.Next;
end;
ds.Close;
FreeAndNil(ds);
{
** note, ansgarbecker, 2007-08-26
VT has a pretty autosorting feature, which keeps the sorting even after having
@@ -2560,17 +2587,9 @@ begin
}
inDataOrQueryTab := FrmIsFocussed and ((PageControlMain.ActivePage = tabData) or (PageControlMain.ActivePage = tabQuery));
PrintList.Enabled := (not inDataOrQueryTab) and FrmIsFocussed;
{***
@note ansgarbecker, 2007-31-03
1. For data-tab-queries (threaded queries) the TDatasource does *not* have
an linked TDataset/TZquery in case of a SQL-error. To avoid an AV with
NIL-reference we have to first check if the Dataset is existant - if not,
assume the datagrid is empty.
2. For query-tab-queries (not threaded) the TZQuery is linked
to the TDatasource and we can safely ask for TDataset.IsEmpty without
causing a NIL-reference.
@todo use the same threaded process for both datagrid and query-grid
}
// Both the Query and the Data grid may have a nil DataSet reference,
// either in case the relevant grid has not been used yet, or when
// an error has occurred.
inDataOrQueryTabNotEmpty := inDataOrQueryTab and
not (
(getActiveGrid.DataSource.DataSet = nil)
@@ -2690,6 +2709,7 @@ begin
WriteString( 'OnlyDBs', ImplodeStr( ';', OnlyDBs ) );
CloseKey;
end;
Free;
end;
end;
end;
@@ -2759,6 +2779,8 @@ begin
VTRowDataListVariables[i-1].Captions.Add( ds.Fields[1].AsString );
ds.Next;
end;
ds.Close;
FreeAndNil(ds);
// STATUS
uptime := 1; // avoids division by zero :)
@@ -2802,6 +2824,8 @@ begin
end;
ds.Next;
end;
ds.Close;
FreeAndNil(ds);
// Tell VirtualTree the number of nodes it will display
ListCommandStats.RootNodeCount := Length(VTRowDataListCommandStats);
@@ -2846,6 +2870,7 @@ begin
ds.Next;
end;
ds.Close;
FreeAndNil(ds);
tabProcessList.Caption := 'Process-List (' + IntToStr(Length(VTRowDataListProcesses)) + ')';
except
on E: Exception do begin
@@ -2933,6 +2958,7 @@ begin
// Destroy old data set.
ds := DataSource2.DataSet;
DataSource2.DataSet := nil;
if ds <> nil then ds.Close;
FreeAndNil( ds );
// set db-aware-component's properties..
DBMemo1.DataField := EmptyStr;
@@ -3059,11 +3085,6 @@ begin
end;
end;
end;
end
else
begin
// Avoid AV for mousewheel-scrolling in empty datagrid
DataSource2.DataSet := nil;
end;
// Ensure controls are in a valid state
ValidateControls();
@@ -3208,6 +3229,8 @@ var
SynCompletionProposal1.ItemList.Add( '\hspace{2}\color{'+ColorToString(clTeal)+'}column\color{clWindowText}\column{}' + ds.FieldByName( 'Field' ).AsString + '\style{-B} ' + ds.FieldByName( 'Type' ).AsString );
ds.Next;
end;
ds.Close;
FreeAndNil(ds);
end;
begin
@@ -3476,6 +3499,7 @@ begin
WriteString( 'OnlyDBs', ImplodeStr( ';', OnlyDBs ) );
CloseKey;
end;
Free;
end;
end;
// Todo: Don't expand node of old database in dbtree, just reload and switch to new one
@@ -3833,6 +3857,7 @@ begin
reg.DeleteValue( reg_value );
end;
reg.CloseKey;
FreeAndNil(reg);
ViewData(self);
@@ -4200,6 +4225,7 @@ begin
popupFilterOpenFile.Items.Add(menuitem);
Inc( i );
end;
Free;
end;
end;
@@ -5153,6 +5179,7 @@ end;
function TMDIChild.ExecUpdateQuery(sql: string; HandleErrors: Boolean = false; DisplayErrors: Boolean = false): Int64;
var
MysqlQuery : TMysqlQuery;
ds: TDataSet;
begin
Result := -1; // Silence compiler warning.
MysqlQuery := nil;
@@ -5178,7 +5205,13 @@ begin
end;
finally
// Cleanup the MysqlQuery object, we won't need it anymore
if MysqlQuery <> nil then FreeAndNil (MysqlQuery);
if MysqlQuery <> nil then begin
if MysqlQuery.MysqlDataset <> nil then
MysqlQuery.MysqlDataset.Close;
ds := MysqlQuery.MysqlDataset;
FreeAndNil(ds);
end;
FreeAndNil (MysqlQuery);
end;
end;
@@ -5196,23 +5229,27 @@ var
res: TMysqlQuery;
begin
res := nil;
result := nil;
try
// Start query execution
res := RunThreadedQuery(sql);
result := res.MysqlDataset;
// Inspect query result code and log / notify user on failure
if res.Result in [MQR_CONNECT_FAIL,MQR_QUERY_FAIL] then
begin
raise Exception.Create(res.Comment);
end;
except
on E: Exception do begin
LogSQL( E.Message, True );
if DisplayErrors then MessageDlg( E.Message, mtError, [mbOK], 0 );
if res <> nil then FreeAndNil(res);
if not HandleErrors then raise THandledSQLError.Create(E.Message);
Result := nil;
try
// Start query execution
res := RunThreadedQuery(sql);
result := res.MysqlDataset;
// Inspect query result code and log / notify user on failure
if res.Result in [MQR_CONNECT_FAIL,MQR_QUERY_FAIL] then
begin
raise Exception.Create(res.Comment);
end;
except
on E: Exception do begin
LogSQL( E.Message, True );
if DisplayErrors then MessageDlg( E.Message, mtError, [mbOK], 0 );
if not HandleErrors then raise THandledSQLError.Create(E.Message);
Result := nil;
end;
end;
finally
FreeAndNil(res);
end;
end;
@@ -5237,6 +5274,7 @@ begin
if ds = nil then exit;
Result := ds.Fields[x].AsString;
ds.Close;
FreeAndNil(ds);
end;
@@ -5248,6 +5286,7 @@ begin
if ds = nil then exit;
Result := ds.Fields.FieldByName(x).AsString;
ds.Close;
FreeAndNil(ds);
end;
{***
@@ -5289,6 +5328,7 @@ begin
ds.Next;
end;
ds.Close;
FreeAndNil(ds);
end;
@@ -5751,6 +5791,8 @@ begin
result := (Trunc(result / ROUNDING) + 1) * ROUNDING;
if result >= RecordCount then result := -1;
end;
ds.Close;
FreeAndNil(ds);
finally
debug( 'GetCalculatedLimit: ' + formatnumber(result) );
end;
@@ -5979,6 +6021,10 @@ begin
sql_default +
sql_extra;
// Cleanup
def.Close;
FreeAndNil(def);
// Fire ALTER query
ExecUpdateQuery( sql_update, False, False );
@@ -6466,7 +6512,7 @@ begin
reg.WriteString( REGPREFIX_COLWIDTHS + List.Name, ColWidths );
reg.WriteString( REGPREFIX_COLSVISIBLE + List.Name, ColsVisible );
reg.WriteString( REGPREFIX_COLPOS + List.Name, ColPos );
FreeAndNil(reg);
end;

View File

@@ -74,6 +74,7 @@ begin
chkSort.Checked := reg.ReadBool(REGNAME_SORTDISPLAYEDCOLUMNS);
reg.CloseKey;
FreeAndNil(reg);
end;
@@ -135,6 +136,7 @@ begin
reg.WriteBool( REGNAME_SORTDISPLAYEDCOLUMNS, chkSort.checked );
reg.CloseKey;
FreeAndNil(reg);
// Signalizes childwin to refresh grid-data
if reg_oldvalue <> reg_newvalue then

View File

@@ -134,6 +134,7 @@ begin
if OpenKey(REGPATH, true) then
WriteString('lastcon', ComboBoxDescription.Text);
CloseKey;
Free;
end;
mysqlconn := TMysqlConn.Create(@cp);
@@ -192,6 +193,7 @@ begin
else
AutoReconnect := false;
CloseKey;
Free;
end;
if ComboBoxDescription.Items.Count > 0 then
begin
@@ -259,6 +261,7 @@ begin
WriteBool('OnlyDBsSorted', CheckBoxSorted.Checked);
CloseKey;
end;
Free;
end;
ComboBoxDescriptionClick(self);
Screen.Cursor := crDefault;
@@ -304,6 +307,7 @@ begin
WriteBool('OnlyDBsSorted', true);
CloseKey;
end;
Free;
end;
EnableDisable(true);
@@ -322,6 +326,7 @@ begin
begin
if not DeleteKey(REGPATH + '\Servers\' + ComboBoxDescription.Text) then
MessageDlg('Error while deleting Key from Registry!', mtError, [mbOK], 0);
Free;
end;
FormShow(self);
end;
@@ -349,6 +354,7 @@ begin
CheckBoxSorted.Checked := false; // for existing connections from older HS-versions always off
CloseKey;
end;
Free;
end;
ButtonSave.Enabled := false;
ButtonSaveAndConnect.Enabled := ButtonSave.Enabled;
@@ -426,6 +432,7 @@ begin
except
MessageDLG('Error on renaming.', mtError, [mbCancel], 0);
end;
Free;
end;
end;

View File

@@ -146,6 +146,8 @@ begin
CheckListBoxFields.Items.Add( ds.Fields[0].AsString );
ds.Next;
end;
ds.Close;
FreeAndNil(ds);
// select all:
for i:=0 to CheckListBoxFields.Items.Count-1 do
@@ -235,6 +237,8 @@ begin
keylist[which].SubParts.add( zq.FieldByName('Sub_part').AsString );
zq.Next;
end;
zq.Close;
FreeAndNil(zq);
for k:=0 to high(keylist) do
begin
if k > 0 then
@@ -290,6 +294,8 @@ begin
end;
zq.Next;
end;
zq.Close;
FreeAndNil(zq);
Mainform.Childwin.MenuRefreshClick(Self);
close;

View File

@@ -15,6 +15,7 @@ object CreateDatabaseForm: TCreateDatabaseForm
Position = poOwnerFormCenter
OnClose = FormClose
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
DesignSize = (
317

View File

@@ -18,6 +18,7 @@ type
comboCollation: TComboBox;
lblPreview: TLabel;
SynMemoPreview: TSynMemo;
procedure FormDestroy(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure comboCharsetChange(Sender: TObject);
procedure Modified(Sender: TObject);
@@ -52,7 +53,7 @@ var
charset: String;
begin
try
dsCollations := Mainform.Childwin.ExecSelectQuery('SHOW COLLATION');
dsCollations := Mainform.Childwin.GetResults('SHOW COLLATION');
// Detect servers default charset
defaultCharset := Mainform.Childwin.GetVar( 'SHOW VARIABLES LIKE '+esc('character_set_server'), 1 );
except
@@ -86,6 +87,12 @@ begin
end;
procedure TCreateDatabaseForm.FormDestroy(Sender: TObject);
begin
if dsCollations <> nil then dsCollations.Close;
FreeAndNil(dsCollations);
end;
{**
Form gets displayed: Set default values.
}

View File

@@ -14,6 +14,7 @@ object CreateTableForm: TCreateTableForm
OldCreateOrder = False
Position = poMainFormCenter
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
DesignSize = (
499

View File

@@ -54,6 +54,7 @@ type
lblCollation: TLabel;
comboCharset: TComboBox;
comboCollation: TComboBox;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure EditTablenameChange(Sender: TObject);
procedure ButtonCancelClick(Sender: TObject);
@@ -135,7 +136,7 @@ var
engineSupport : String;
begin
try
dsCollations := Mainform.Childwin.ExecSelectQuery('SHOW COLLATION');
dsCollations := Mainform.Childwin.GetResults('SHOW COLLATION');
// Detect servers default charset
defaultCharset := Mainform.Childwin.GetVar( 'SHOW VARIABLES LIKE '+esc('character_set_server'), 1 );
except
@@ -163,7 +164,7 @@ begin
comboCollation.Enabled := dsCollations <> nil;
lblCollation.Enabled := comboCollation.Enabled;
dsEngines := Mainform.Childwin.ExecSelectQuery('SHOW ENGINES', True);
dsEngines := Mainform.Childwin.GetResults('SHOW ENGINES', True);
if dsEngines <> nil then
begin
ComboboxTableType.Style := csDropDownList; // No editing needed
@@ -181,10 +182,18 @@ begin
dsEngines.Next;
end;
ComboboxTableType.Items.EndUpdate;
dsEngines.Close;
end;
FreeAndNil(dsEngines);
end;
procedure TCreateTableForm.FormDestroy(Sender: TObject);
begin
if dsCollations <> nil then dsCollations.Close;
FreeAndNil(dsCollations);
end;
procedure TCreateTableForm.ButtonCancelClick(Sender: TObject);
begin
ModalResult := mrCancel;

View File

@@ -72,6 +72,7 @@ begin
reg_name := 'ORDERCLAUSE_' + Mainform.Childwin.ActiveDatabase + '.' + Mainform.Childwin.SelectedTable;
OldOrderClause := reg.ReadString(reg_name);
reg.CloseKey;
FreeAndNil(reg);
// Create one OrderColumns record for each grid.SortColumn
grid := Mainform.Childwin.gridData;
@@ -353,6 +354,7 @@ begin
reg.OpenKey( REGPATH + '\Servers\' + Mainform.Childwin.Description, true );
reg.WriteString( reg_name, ComposeOrderClause );
reg.CloseKey;
FreeAndNil(reg);
end;

View File

@@ -273,6 +273,7 @@ begin
end;
if ValueExists('ExportSQL_WindowWidth') then Width := ReadInteger('ExportSQL_WindowWidth');
if ValueExists('ExportSQL_WindowHeight') then Height := ReadInteger('ExportSQL_WindowHeight');
Free;
end;
if EditFileName.Text = '' then
@@ -746,6 +747,8 @@ begin
begin
Query := cwin.GetResults('SHOW CREATE TABLE ' + sourceMask(checkListTables.Items[i]));
sql := Query.Fields[1].AsString;
Query.Close;
FreeAndNil(Query);
sql := fixNewlines(sql);
if Pos('DEFAULT CHARSET', sql) > 0 then begin
Insert('/*!40100 ', sql, Pos('DEFAULT CHARSET', sql));
@@ -812,6 +815,8 @@ begin
if j < Query.Fieldcount then
sql := sql + ',' + crlf;
end;
Query.Close;
FreeAndNil(Query);
// Keys:
Query := cwin.GetResults( 'SHOW KEYS FROM ' + sourceMask(checkListTables.Items[i]));
@@ -850,6 +855,8 @@ begin
keylist[which].Columns.add(destMask(Query.Fields[4].AsString)); // add column(s)
Query.Next;
end;
Query.Close;
FreeAndNil(Query);
for k:=0 to high(keylist) do
begin
if k > 0 then
@@ -916,6 +923,8 @@ begin
Query.Next;
end;
columnnames := columnnames+')';
Query.Close;
FreeAndNil(Query);
if tofile then
begin
@@ -1092,6 +1101,7 @@ begin
insertquery := '';
end;
Query.Close;
FreeAndNil(Query);
end;
// Set back to local setting:
setLocales;
@@ -1463,6 +1473,7 @@ begin
WriteInteger('ExportSQL_WindowWidth', Width );
WriteInteger('ExportSQL_WindowHeight', Height );
CloseKey();
Free;
end;
end;

View File

@@ -261,6 +261,8 @@ begin
klist[TempKeys.IndexOf(ds.Fields[2].AsString)].Columns.Add(ds.Fields[4].AsString);
ds.Next;
end;
ds.Close;
FreeAndNil(ds);
listColumnsAvailable.Items := GetVTCaptions(cwin.ListColumns);
showkeys();

View File

@@ -154,6 +154,8 @@ begin
cols[length(cols)-1].Quote := false;
ds.Next;
end;
ds.Close;
FreeAndNil(ds);
DisplayColumns(self);
end;
end;

View File

@@ -137,7 +137,7 @@ begin
end;
FINALLY
zq.ParamCheck := false;
FreeAndNil(zq);
screen.Cursor := crDefault;
Close();
END;

View File

@@ -145,8 +145,8 @@ begin
chkReplace.Checked := reg.ReadBool('CSVImportReplace');
if reg.ValueExists('CSVImportIgnore') then
chkIgnore.Checked := reg.ReadBool('CSVImportIgnore');
Free;
end;
end;
@@ -186,6 +186,8 @@ begin
chklistColumns.Items.Add(ds.Fields[0].AsString);
ds.Next;
end;
ds.Close;
FreeAndNil(ds);
end;
// select all:
@@ -230,6 +232,7 @@ begin
reg.WriteBool( 'CSVImportReplace', chkReplace.Checked );
reg.WriteBool( 'CSVImportIgnore', chkIgnore.Checked );
end;
FreeAndNil(reg);
query := 'LOAD DATA ';

View File

@@ -389,6 +389,7 @@ begin
WriteInteger('ToolBarDataTop', ToolBarData.Top);
end;
CloseKey;
Free;
end;
GetTempPath(MAX_PATH, buffer);
filename := buffer;
@@ -446,6 +447,7 @@ begin
ToolBarData.Top := ReadInteger('ToolBarDataTop');
end;
CloseKey;
Free;
end;
// Beautify appversion
@@ -883,6 +885,7 @@ begin
WriteString('CSVEncloser', FieldEncl);
WriteString('CSVTerminator', LineSep);
closekey();
Free;
end;
Screen.Cursor := crDefault;
end;

View File

@@ -25,6 +25,7 @@ type
constructor Create(AConn : POpenConnProf);
destructor Destroy(); override;
function Connect() : Integer;
procedure Disconnect();
property IsConnected : Boolean read GetIsConnected;
property IsAlive : Boolean read GetIsAlive;
property Connection : TZConnection read FConn;
@@ -49,6 +50,7 @@ function TMysqlConn.Connect(): Integer;
begin
FLastError := '';
if FConn.Connected then FConn.Disconnect;
with FOpenConn.MysqlParams do
begin
FConn.Protocol := 'mysql';
@@ -80,9 +82,15 @@ begin
end;
procedure TMysqlConn.Disconnect;
begin
if FConn.Connected then FConn.Disconnect;
end;
destructor TMysqlConn.Destroy;
begin
if FConn.Connected then FConn.Disconnect;
FreeAndNil (FConn);
inherited;
end;

View File

@@ -56,11 +56,11 @@ type
Comment : String;
end;
TMysqlConnectThread = class(TThread)
{*TMysqlConnectThread = class(TThread)
private
protected
public
end;
end;*}
TMysqlQueryThread = class(TThread)
private

View File

@@ -129,6 +129,8 @@ begin
sql := StringReplace(pseudoSql, '$table', mainform.mask(TablesCheckListBox.Items[i]), [rfReplaceAll]);
ds := Mainform.ChildWin.GetResults(sql);
AddResults(ds);
ds.Close;
FreeAndNil(ds);
TablesCheckListBox.Checked[i] := false;
end;
end;

View File

@@ -132,6 +132,7 @@ begin
ParentNode.DeleteChildren;
topic := ParentNode.Text;
end;
ds := nil;
try
Screen.Cursor := crHourglass;
ds := m.GetResults( 'HELP "'+topic+'"' );
@@ -154,6 +155,7 @@ begin
ds.Next;
end;
finally
if ds <> nil then ds.Close;
FreeAndNil( ds );
Screen.Cursor := crDefault;
end;
@@ -261,6 +263,7 @@ begin
Caption := DEFAULT_WINDOW_CAPTION;
result := false; // Keyword not found yet
ds := nil;
if Keyword <> '' then
try
Screen.Cursor := crHourglass;
@@ -278,6 +281,7 @@ begin
result := true;
end;
finally
if ds <> nil then ds.Close;
FreeAndNil( ds );
Screen.Cursor := crDefault;
end;

View File

@@ -17,6 +17,7 @@ object tbl_properties_form: Ttbl_properties_form
Position = poMainFormCenter
OnClose = FormClose
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13

View File

@@ -35,6 +35,7 @@ type
popupSynMemo: TPopupMenu;
menuCopy: TMenuItem;
menuSelectAll: TMenuItem;
procedure FormDestroy(Sender: TObject);
procedure comboCharsetChange(Sender: TObject);
procedure editNameChange(Sender: TObject);
@@ -71,8 +72,8 @@ var
charset : String;
begin
try
dsEngines := Mainform.Childwin.ExecSelectQuery('SHOW ENGINES');
dsCollations := Mainform.Childwin.ExecSelectQuery('SHOW COLLATION');
dsEngines := Mainform.Childwin.GetResults('SHOW ENGINES');
dsCollations := Mainform.Childwin.GetResults('SHOW COLLATION');
except
// Ignore it when the above statements don't work on pre 4.1 servers.
// If the list(s) are nil, disable the combobox(es), so we create the db without charset.
@@ -125,6 +126,14 @@ begin
end;
procedure Ttbl_properties_form.FormDestroy(Sender: TObject);
begin
if dsEngines <> nil then dsEngines.Close;
FreeAndNil(dsEngines);
if dsCollations <> nil then dsCollations.Close;
FreeAndNil(dsCollations);
end;
{**
Form gets displayed.
}
@@ -185,6 +194,8 @@ begin
editAutoincrement.Enabled := True;
end;
lblAutoincrement.Enabled := editAutoincrement.Enabled;
ds.Close;
FreeAndNil(ds);
// SQL preview
sql := 'SHOW CREATE TABLE ';

View File

@@ -221,5 +221,8 @@ end;
initialization
working := TThreadList.Create;
finalization
FreeAndNil(working);
end.

View File

@@ -88,6 +88,7 @@ type
procedure GetResColumns;
function getColumnNamesOrValues( which: String = 'columns' ): TStringList;
function getPrivColumns( privtable: String ): TDataSet;
procedure clearCache;
private
@@ -250,7 +251,9 @@ begin
WriteBool('Compressed', false);
WriteString('OnlyDBs', '');
CloseKey;
Free;
end;
Free;
end;
priv := '';
@@ -355,6 +358,7 @@ begin
tnu.SelectedIndex := ICONINDEX_FIELD;
ZQueryColumnNames.Next;
end;
ZQueryColumnNames.Close;
FreeAndNil( ZQueryColumnNames );
end;
@@ -824,11 +828,7 @@ end;
procedure TUserManagerForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
// free memory
FreeAndNil( ZQueryUsers );
FreeAndNil( ZQueryDBs );
FreeAndNil( ZQueryTables );
FreeAndNil( ZQueryColumns );
clearCache;
end;
@@ -923,13 +923,30 @@ begin
EditUserWindow(self);
end;
procedure TUserManagerForm.Button1Click(Sender: TObject);
procedure TUserManagerForm.clearCache;
begin
// free memory
if ZQueryUsers <> nil then ZQueryUsers.Close;
FreeAndNil( ZQueryUsers );
if ZQueryDBs <> nil then ZQueryDBs.Close;
FreeAndNil( ZQueryDBs );
if ZQueryTables <> nil then ZQueryTables.Close;
FreeAndNil( ZQueryTables );
if ZQueryColumns <> nil then ZQueryColumns.Close;
FreeAndNil( ZQueryColumns );
if ColumnsUsers <> nil then ColumnsUsers.Close;
FreeAndNil(ColumnsUsers);
if ColumnsDB <> nil then ColumnsDB.Close;
FreeAndNil(ColumnsDB);
if ColumnsTables <> nil then ColumnsTables.Close;
FreeAndNil(ColumnsTables);
if ColumnsColumns <> nil then ColumnsColumns.Close;
FreeAndNil(ColumnsColumns);
end;
procedure TUserManagerForm.Button1Click(Sender: TObject);
begin
clearCache;
ShowPrivilegesControls(false, true, false);
TreeViewUsers.Items.Clear;
PageControl1.OnChange(self);