Explorar el Código

+ Fixed bug #5070

git-svn-id: trunk@3381 -
joost hace 19 años
padre
commit
1d226830f2
Se han modificado 1 ficheros con 14 adiciones y 11 borrados
  1. 14 11
      fcl/db/dataset.inc

+ 14 - 11
fcl/db/dataset.inc

@@ -1275,7 +1275,7 @@ end;
 Procedure TDataset.DoInsertAppend(DoAppend : Boolean);
 Procedure TDataset.DoInsertAppend(DoAppend : Boolean);
 
 
 
 
-  procedure DoInsert;
+  procedure DoInsert(DoAppend : Boolean);
 
 
   Var BookBeforeInsert : TBookmarkStr;
   Var BookBeforeInsert : TBookmarkStr;
       TempBuf : pointer;
       TempBuf : pointer;
@@ -1286,18 +1286,22 @@ Procedure TDataset.DoInsertAppend(DoAppend : Boolean);
   If FRecordcount > 0 then
   If FRecordcount > 0 then
     BookBeforeInsert:=Bookmark;
     BookBeforeInsert:=Bookmark;
 
 
-  if FActiveRecord < FRecordCount-1 then
+  if not DoAppend then
     begin
     begin
-    TempBuf := FBuffers[FBuffercount];
-    move(FBuffers[FActiveRecord],FBuffers[FActiveRecord+1],(Fbuffercount-FActiveRecord)*sizeof(FBuffers[0]));
-    FBuffers[FActiveRecord]:=TempBuf;
+    if FRecordCount > 0 then
+      begin
+      TempBuf := FBuffers[FBuffercount];
+      move(FBuffers[FActiveRecord],FBuffers[FActiveRecord+1],(Fbuffercount-FActiveRecord)*sizeof(FBuffers[0]));
+      FBuffers[FActiveRecord]:=TempBuf;
+      end;
     end
     end
   else if FRecordcount=FBuffercount then
   else if FRecordcount=FBuffercount then
     shiftbuffersbackward
     shiftbuffersbackward
-  else begin
+  else
+    begin
     if FRecordCount>0 then
     if FRecordCount>0 then
-    inc(FActiveRecord);
-  end;
+      inc(FActiveRecord);
+    end;
 
 
   // Active buffer is now edit buffer. Initialize.
   // Active buffer is now edit buffer. Initialize.
   InitRecord(FBuffers[FActiveRecord]);
   InitRecord(FBuffers[FActiveRecord]);
@@ -1339,8 +1343,7 @@ begin
 {$ifdef dsdebug}
 {$ifdef dsdebug}
     Writeln ('going to insert mode');
     Writeln ('going to insert mode');
 {$endif}
 {$endif}
-
-    DoInsert;
+    DoInsert(false);
     end
     end
   else
   else
     begin
     begin
@@ -1352,7 +1355,7 @@ begin
     GetPriorRecords;
     GetPriorRecords;
     if FRecordCount>0 then
     if FRecordCount>0 then
       FActiveRecord:=FRecordCount-1;
       FActiveRecord:=FRecordCount-1;
-    DoInsert;
+    DoInsert(True);
     SetBookmarkFlag(ActiveBuffer,bfEOF);
     SetBookmarkFlag(ActiveBuffer,bfEOF);
     FBOF :=False;
     FBOF :=False;
     FEOF := true;
     FEOF := true;