Browse Source

check FSQLTrans object inanstintiation before using it

motaz 11 năm trước cách đây
mục cha
commit
69ca629bb2
4 tập tin đã thay đổi với 23 bổ sung21 xóa
  1. 8 8
      main.lfm
  2. 11 11
      main.lrs
  3. 2 1
      main.pas
  4. 2 1
      scriptdb.pas

+ 8 - 8
main.lfm

@@ -5,7 +5,7 @@ object fmMain: TfmMain
   Width = 1024
   ActiveControl = tvMain
   Caption = 'TurboBird Admin for FireBird'
-  ClientHeight = 621
+  ClientHeight = 617
   ClientWidth = 1024
   Color = clWhite
   Font.Name = 'Sans'
@@ -18,7 +18,7 @@ object fmMain: TfmMain
   LCLVersion = '1.2.2.0'
   object tvMain: TTreeView
     Left = 0
-    Height = 601
+    Height = 596
     Top = 0
     Width = 360
     Align = alLeft
@@ -38,14 +38,14 @@ object fmMain: TfmMain
   end
   object Splitter1: TSplitter
     Left = 360
-    Height = 601
+    Height = 596
     Top = 0
     Width = 14
     Beveled = True
   end
   object PageControl1: TPageControl
     Left = 377
-    Height = 594
+    Height = 589
     Top = 3
     Width = 644
     ActivePage = TabSheet1
@@ -65,8 +65,8 @@ object fmMain: TfmMain
     object TabSheet1: TTabSheet
       BorderWidth = 1
       Caption = 'Main'
-      ClientHeight = 563
-      ClientWidth = 636
+      ClientHeight = 559
+      ClientWidth = 640
       Font.Color = clNavy
       Font.Name = 'Arial'
       ParentFont = False
@@ -506,8 +506,8 @@ object fmMain: TfmMain
   end
   object StatusBar1: TStatusBar
     Left = 0
-    Height = 20
-    Top = 601
+    Height = 21
+    Top = 596
     Width = 1024
     Panels = <    
       item

+ 11 - 11
main.lrs

@@ -3,11 +3,11 @@
 LazarusResources.Add('TfmMain','FORMDATA',[
   'TPF0'#7'TfmMain'#6'fmMain'#4'Left'#3#244#0#6'Height'#3#128#2#3'Top'#3#139#0#5
   +'Width'#3#0#4#13'ActiveControl'#7#6'tvMain'#7'Caption'#6#28'TurboBird Admin '
-  +'for FireBird'#12'ClientHeight'#3'm'#2#11'ClientWidth'#3#0#4#5'Color'#7#7'cl'
+  +'for FireBird'#12'ClientHeight'#3'i'#2#11'ClientWidth'#3#0#4#5'Color'#7#7'cl'
   +'White'#9'Font.Name'#6#4'Sans'#4'Menu'#7#9'MainMenu1'#10'OnActivate'#7#12'Fo'
   +'rmActivate'#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreate'#9'OnDest'
   +'roy'#7#11'FormDestroy'#8'Position'#7#14'poScreenCenter'#10'LCLVersion'#6#7
-  +'1.2.2.0'#0#9'TTreeView'#6'tvMain'#4'Left'#2#0#6'Height'#3'Y'#2#3'Top'#2#0#5
+  +'1.2.2.0'#0#9'TTreeView'#6'tvMain'#4'Left'#2#0#6'Height'#3'T'#2#3'Top'#2#0#5
   +'Width'#3'h'#1#5'Align'#7#6'alLeft'#15'BackgroundColor'#7#7'clWhite'#5'Color'
   +#7#7'clCream'#15'ExpandSignColor'#7#8'clMaroon'#13'HideSelection'#8#6'Images'
   +#7#10'ImageList1'#6'Indent'#2#25#8'ReadOnly'#9#16'RightClickSelect'#9#9'Show'
@@ -15,20 +15,20 @@ LazarusResources.Add('TfmMain','FORMDATA',[
   +#7#14'tvMainExpanded'#7'Options'#11#17'tvoAutoItemHeight'#21'tvoKeepCollapse'
   +'dNodes'#11'tvoReadOnly'#19'tvoRightClickSelect'#14'tvoShowButtons'#11'tvoSh'
   +'owRoot'#11'tvoToolTips'#0#0#0#9'TSplitter'#9'Splitter1'#4'Left'#3'h'#1#6'He'
-  +'ight'#3'Y'#2#3'Top'#2#0#5'Width'#2#14#7'Beveled'#9#0#0#12'TPageControl'#12
-  +'PageControl1'#4'Left'#3'y'#1#6'Height'#3'R'#2#3'Top'#2#3#5'Width'#3#132#2#10
+  +'ight'#3'T'#2#3'Top'#2#0#5'Width'#2#14#7'Beveled'#9#0#0#12'TPageControl'#12
+  +'PageControl1'#4'Left'#3'y'#1#6'Height'#3'M'#2#3'Top'#2#3#5'Width'#3#132#2#10
   +'ActivePage'#7#9'TabSheet1'#5'Align'#7#8'alClient'#18'BorderSpacing.Left'#2#1
   +#17'BorderSpacing.Top'#2#1#19'BorderSpacing.Right'#2#1#20'BorderSpacing.Bott'
   +'om'#2#2#20'BorderSpacing.Around'#2#2#25'BorderSpacing.InnerBorder'#2#1#9'Fo'
   +'nt.Name'#6#4'Sans'#10'ParentFont'#8#8'TabIndex'#2#0#8'TabOrder'#2#2#17'OnCl'
   +'oseTabClicked'#7#27'PageControl1CloseTabClicked'#7'Options'#11#20'nboHidePa'
   +'geListPopup'#0#0#9'TTabSheet'#9'TabSheet1'#11'BorderWidth'#2#1#7'Caption'#6
-  +#4'Main'#12'ClientHeight'#3'3'#2#11'ClientWidth'#3'|'#2#10'Font.Color'#7#6'c'
-  +'lNavy'#9'Font.Name'#6#5'Arial'#10'ParentFont'#8#0#7'TBitBtn'#11'bbRestoreDB'
-  +#4'Left'#2#3#6'Height'#2']'#3'Top'#3#216#0#5'Width'#3#208#0#7'Caption'#6#16
-  +'Restore Database'#5'Color'#7#7'clCream'#9'Font.Name'#6#4'Sans'#10'Glyph.Dat'
-  +'a'#10':'#16#0#0'6'#16#0#0'BM6'#16#0#0#0#0#0#0'6'#0#0#0'('#0#0#0' '#0#0#0' '
-  +#0#0#0#1#0' '#0#0#0#0#0#0#16#0#0'd'#0#0#0'd'#0#0#0#0#0#0#0#0#0#0#0#255#255
+  +#4'Main'#12'ClientHeight'#3'/'#2#11'ClientWidth'#3#128#2#10'Font.Color'#7#6
+  +'clNavy'#9'Font.Name'#6#5'Arial'#10'ParentFont'#8#0#7'TBitBtn'#11'bbRestoreD'
+  +'B'#4'Left'#2#3#6'Height'#2']'#3'Top'#3#216#0#5'Width'#3#208#0#7'Caption'#6
+  +#16'Restore Database'#5'Color'#7#7'clCream'#9'Font.Name'#6#4'Sans'#10'Glyph.'
+  +'Data'#10':'#16#0#0'6'#16#0#0'BM6'#16#0#0#0#0#0#0'6'#0#0#0'('#0#0#0' '#0#0#0
+  +' '#0#0#0#1#0' '#0#0#0#0#0#0#16#0#0'd'#0#0#0'd'#0#0#0#0#0#0#0#0#0#0#0#255#255
   +#255#0#255#255#255#0#255#255#255#0#255#255#255#0#255#255#255#0#255#255#255#0
   +#255#255#255#0#255#255#255#0#255#255#255#0#255#255#255#0#0#0#0#1'UUU'#3'@``'
   +#8'NNN'#13'UUU'#18'QQQ'#22'YYY'#23'MYY'#20'UUU'#15'MfM'#10'fff'#5#128#128#128
@@ -593,7 +593,7 @@ LazarusResources.Add('TfmMain','FORMDATA',[
   +#255#0#255#255#255#0#255#255#255#0#255#255#255#0#255#255#255#0#255#255#255#0
   +#255#255#255#0#255#255#255#0#255#255#255#0#255#255#255#0#255#255#255#0#255
   +#255#255#0#7'OnClick'#7#15'mnCreateDBClick'#10'ParentFont'#8#8'TabOrder'#2#2
-  +#0#0#0#0#10'TStatusBar'#10'StatusBar1'#4'Left'#2#0#6'Height'#2#20#3'Top'#3'Y'
+  +#0#0#0#0#10'TStatusBar'#10'StatusBar1'#4'Left'#2#0#6'Height'#2#21#3'Top'#3'T'
   +#2#5'Width'#3#0#4#6'Panels'#14#1#5'Width'#3#250#0#0#1#5'Width'#3#200#0#0#0#11
   +'SimplePanel'#8#0#0#9'TMainMenu'#9'MainMenu1'#4'left'#2'?'#3'top'#2'q'#0#9'T'
   +'MenuItem'#9'MenuItem1'#7'Caption'#6#5'&File'#0#9'TMenuItem'#10'mnCreateDB'#7

+ 2 - 1
main.pas

@@ -2474,7 +2474,8 @@ begin
   SQLQuery1.Close;
   {A bit unclear why the transaction needs to be committed but at least do it
   before changing the query's transaction}
-  FSQLTransaction.Commit;
+  if (Assigned(FSQLTransaction)) then
+    FSQLTransaction.Commit;
   Rec:= RegisteredDatabases[DatabaseIndex];
   SetConnection(DatabaseIndex);
   SQLQuery1.SQL.Text:= format(QueryTemplate,[ATableName]);

+ 2 - 1
scriptdb.pas

@@ -6,7 +6,7 @@ unit Scriptdb;
 interface
 
 uses
-  Classes, SysUtils, turbocommon;
+  Classes, SysUtils, turbocommon, dialogs;
 
 
 function ScriptAllRoles(dbIndex: Integer; var List: TStringList): Boolean;
@@ -223,6 +223,7 @@ begin
   ScriptList.Clear;
   ScriptList.Add('create table ' + ATableName + ' (');
   CalculatedList:= TStringList.Create;
+
   try
     // Fields
     with fmMain.SQLQuery1 do