49 |
|
{$ELSE} |
50 |
|
unix, |
51 |
|
{$ENDIF} |
52 |
< |
SysUtils, Classes, Forms, Controls, IBDatabase, |
53 |
< |
IBExternals, IB, IBHeader, IBSQL, Db, |
52 |
> |
SysUtils, Classes, IBDatabase, IBExternals, IB, IBHeader, IBSQL, Db, |
53 |
|
IBUtils, IBBlob, IBSQLParser; |
54 |
|
|
55 |
|
const |
657 |
|
|
658 |
|
{ TIBDSBlobStream } |
659 |
|
TIBDSBlobStream = class(TStream) |
660 |
+ |
private |
661 |
+ |
FHasWritten: boolean; |
662 |
|
protected |
663 |
|
FField: TField; |
664 |
|
FBlobStream: TIBBlobStream; |
665 |
|
public |
666 |
|
constructor Create(AField: TField; ABlobStream: TIBBlobStream; |
667 |
|
Mode: TBlobStreamMode); |
668 |
+ |
destructor Destroy; override; |
669 |
|
function Read(var Buffer; Count: Longint): Longint; override; |
670 |
|
function Seek(Offset: Longint; Origin: Word): Longint; override; |
671 |
|
procedure SetSize(NewSize: Longint); override; |
1927 |
|
procedure TIBCustomDataSet.InternalRefreshRow; |
1928 |
|
var |
1929 |
|
Buff: PChar; |
1928 |
– |
SetCursor: Boolean; |
1930 |
|
ofs: DWORD; |
1931 |
|
Qry: TIBSQL; |
1932 |
|
begin |
1933 |
< |
if Assigned(Database) and not Database.SQLHourGlass then |
1933 |
< |
SetCursor := False |
1934 |
< |
else |
1935 |
< |
SetCursor := (GetCurrentThreadID = MainThreadID) and (Screen.Cursor = crDefault); |
1936 |
< |
if SetCursor then |
1937 |
< |
Screen.Cursor := crHourGlass; |
1933 |
> |
FBase.SetCursor; |
1934 |
|
try |
1935 |
|
Buff := GetActiveBuf; |
1936 |
|
if CanRefresh then |
1974 |
|
else |
1975 |
|
IBError(ibxeCannotRefresh, [nil]); |
1976 |
|
finally |
1977 |
< |
if SetCursor and (Screen.Cursor = crHourGlass) then |
1982 |
< |
Screen.Cursor := crDefault; |
1977 |
> |
FBase.RestoreCursor; |
1978 |
|
end; |
1979 |
|
end; |
1980 |
|
|
2045 |
|
|
2046 |
|
procedure TIBCustomDataSet.InternalPrepare; |
2047 |
|
var |
2053 |
– |
SetCursor: Boolean; |
2048 |
|
DidActivate: Boolean; |
2049 |
|
begin |
2050 |
|
if FInternalPrepared then |
2051 |
|
Exit; |
2052 |
|
DidActivate := False; |
2053 |
< |
if Assigned(Database) and not Database.SQLHourGlass then |
2060 |
< |
SetCursor := False |
2061 |
< |
else |
2062 |
< |
SetCursor := (GetCurrentThreadID = MainThreadID) and (Screen.Cursor = crDefault); |
2063 |
< |
if SetCursor then |
2064 |
< |
Screen.Cursor := crHourGlass; |
2053 |
> |
FBase.SetCursor; |
2054 |
|
try |
2055 |
|
ActivateConnection; |
2056 |
|
DidActivate := ActivateTransaction; |
2086 |
|
finally |
2087 |
|
if DidActivate then |
2088 |
|
DeactivateTransaction; |
2089 |
< |
if SetCursor and (Screen.Cursor = crHourGlass) then |
2101 |
< |
Screen.Cursor := crDefault; |
2089 |
> |
FBase.RestoreCursor; |
2090 |
|
end; |
2091 |
|
end; |
2092 |
|
|
2729 |
|
|
2730 |
|
procedure TIBCustomDataSet.FetchAll; |
2731 |
|
var |
2744 |
– |
SetCursor: Boolean; |
2732 |
|
{$IF FPC_FULLVERSION >= 20700 } |
2733 |
|
CurBookmark: TBookmark; |
2734 |
|
{$ELSE} |
2735 |
|
CurBookmark: string; |
2736 |
|
{$ENDIF} |
2737 |
|
begin |
2738 |
< |
if Assigned(Database) and not Database.SQLHourGlass then |
2739 |
< |
SetCursor := False |
2753 |
< |
else |
2754 |
< |
SetCursor := (GetCurrentThreadID = MainThreadID) and (Screen.Cursor = crDefault); |
2755 |
< |
if SetCursor then |
2756 |
< |
Screen.Cursor := crHourGlass; |
2757 |
< |
try |
2738 |
> |
FBase.SetCursor; |
2739 |
> |
try |
2740 |
|
if FQSelect.EOF or not FQSelect.Open then |
2741 |
|
exit; |
2742 |
|
DisableControls; |
2748 |
|
EnableControls; |
2749 |
|
end; |
2750 |
|
finally |
2751 |
< |
if SetCursor and (Screen.Cursor = crHourGlass) then |
2770 |
< |
Screen.Cursor := crDefault; |
2751 |
> |
FBase.RestoreCursor; |
2752 |
|
end; |
2753 |
|
end; |
2754 |
|
|
2809 |
|
for i := 0 to Length(FAliasNameMap) - 1 do |
2810 |
|
if FAliasNameMap[i] = aliasName then |
2811 |
|
begin |
2812 |
< |
Result := FieldDefs[i+1]; |
2812 |
> |
Result := FieldDefs[i]; |
2813 |
|
Exit |
2814 |
|
end; |
2815 |
|
end; |
2903 |
|
if not Accept and (GetMode = gmCurrent) then |
2904 |
|
GetMode := gmPrior; |
2905 |
|
except |
2906 |
< |
// Application.HandleException(Self); |
2906 |
> |
// FBase.HandleException(Self); |
2907 |
|
end; |
2908 |
|
end; |
2909 |
|
RestoreState(SaveState); |
3084 |
|
procedure TIBCustomDataSet.InternalDelete; |
3085 |
|
var |
3086 |
|
Buff: PChar; |
3106 |
– |
SetCursor: Boolean; |
3087 |
|
begin |
3088 |
< |
if Assigned(Database) and not Database.SQLHourGlass then |
3109 |
< |
SetCursor := False |
3110 |
< |
else |
3111 |
< |
SetCursor := (GetCurrentThreadID = MainThreadID) and (Screen.Cursor = crDefault); |
3112 |
< |
if SetCursor then |
3113 |
< |
Screen.Cursor := crHourGlass; |
3088 |
> |
FBase.SetCursor; |
3089 |
|
try |
3090 |
|
Buff := GetActiveBuf; |
3091 |
|
if CanDelete then |
3110 |
|
end else |
3111 |
|
IBError(ibxeCannotDelete, [nil]); |
3112 |
|
finally |
3113 |
< |
if SetCursor and (Screen.Cursor = crHourGlass) then |
3139 |
< |
Screen.Cursor := crDefault; |
3113 |
> |
FBase.RestoreCursor; |
3114 |
|
end; |
3115 |
|
end; |
3116 |
|
|
3126 |
|
|
3127 |
|
procedure TIBCustomDataSet.InternalHandleException; |
3128 |
|
begin |
3129 |
< |
Application.HandleException(Self) |
3129 |
> |
FBase.HandleException(Self) |
3130 |
|
end; |
3131 |
|
|
3132 |
|
procedure TIBCustomDataSet.InternalInitFieldDefs; |
3511 |
|
end; |
3512 |
|
|
3513 |
|
procedure TIBCustomDataSet.InternalOpen; |
3540 |
– |
var |
3541 |
– |
SetCursor: Boolean; |
3514 |
|
|
3515 |
|
function RecordDataLength(n: Integer): Long; |
3516 |
|
begin |
3518 |
|
end; |
3519 |
|
|
3520 |
|
begin |
3521 |
< |
if Assigned(Database) and not Database.SQLHourGlass then |
3550 |
< |
SetCursor := False |
3551 |
< |
else |
3552 |
< |
SetCursor := (GetCurrentThreadID = MainThreadID) and (Screen.Cursor = crDefault); |
3553 |
< |
if SetCursor then |
3554 |
< |
Screen.Cursor := crHourGlass; |
3521 |
> |
FBase.SetCursor; |
3522 |
|
try |
3523 |
|
ActivateConnection; |
3524 |
|
ActivateTransaction; |
3579 |
|
else |
3580 |
|
FQSelect.ExecQuery; |
3581 |
|
finally |
3582 |
< |
if SetCursor and (Screen.Cursor = crHourGlass) then |
3616 |
< |
Screen.Cursor := crDefault; |
3582 |
> |
FBase.RestoreCursor; |
3583 |
|
end; |
3584 |
|
end; |
3585 |
|
|
3587 |
|
var |
3588 |
|
Qry: TIBSQL; |
3589 |
|
Buff: PChar; |
3624 |
– |
SetCursor: Boolean; |
3590 |
|
bInserting: Boolean; |
3591 |
|
begin |
3592 |
< |
if Assigned(Database) and not Database.SQLHourGlass then |
3628 |
< |
SetCursor := False |
3629 |
< |
else |
3630 |
< |
SetCursor := (GetCurrentThreadID = MainThreadID) and (Screen.Cursor = crDefault); |
3631 |
< |
if SetCursor then |
3632 |
< |
Screen.Cursor := crHourGlass; |
3592 |
> |
FBase.SetCursor; |
3593 |
|
try |
3594 |
|
Buff := GetActiveBuf; |
3595 |
|
CheckEditState; |
3627 |
|
if bInserting then |
3628 |
|
Inc(FRecordCount); |
3629 |
|
finally |
3630 |
< |
if SetCursor and (Screen.Cursor = crHourGlass) then |
3671 |
< |
Screen.Cursor := crDefault; |
3630 |
> |
FBase.RestoreCursor; |
3631 |
|
end; |
3632 |
|
end; |
3633 |
|
|
3890 |
|
procedure TIBCustomDataSet.InternalExecQuery; |
3891 |
|
var |
3892 |
|
DidActivate: Boolean; |
3934 |
– |
SetCursor: Boolean; |
3893 |
|
begin |
3894 |
|
DidActivate := False; |
3895 |
< |
if Assigned(Database) and not Database.SQLHourGlass then |
3938 |
< |
SetCursor := False |
3939 |
< |
else |
3940 |
< |
SetCursor := (GetCurrentThreadID = MainThreadID) and (Screen.Cursor = crDefault); |
3941 |
< |
if SetCursor then |
3942 |
< |
Screen.Cursor := crHourGlass; |
3895 |
> |
FBase.SetCursor; |
3896 |
|
try |
3897 |
|
ActivateConnection; |
3898 |
|
DidActivate := ActivateTransaction; |
3909 |
|
finally |
3910 |
|
if DidActivate then |
3911 |
|
DeactivateTransaction; |
3912 |
< |
if SetCursor and (Screen.Cursor = crHourGlass) then |
3960 |
< |
Screen.Cursor := crDefault; |
3912 |
> |
FBase.RestoreCursor; |
3913 |
|
end; |
3914 |
|
end; |
3915 |
|
|
4281 |
|
FBlobStream.Truncate; |
4282 |
|
end; |
4283 |
|
|
4284 |
+ |
destructor TIBDSBlobStream.Destroy; |
4285 |
+ |
begin |
4286 |
+ |
if FHasWritten then |
4287 |
+ |
TIBCustomDataSet(FField.DataSet).DataEvent(deFieldChange, PtrInt(FField)); |
4288 |
+ |
inherited Destroy; |
4289 |
+ |
end; |
4290 |
+ |
|
4291 |
|
function TIBDSBlobStream.Read(var Buffer; Count: Longint): Longint; |
4292 |
|
begin |
4293 |
|
result := FBlobStream.Read(Buffer, Count); |
4310 |
|
TIBCustomDataSet(FField.DataSet).RecordModified(True); |
4311 |
|
TBlobField(FField).Modified := true; |
4312 |
|
result := FBlobStream.Write(Buffer, Count); |
4313 |
< |
TIBCustomDataSet(FField.DataSet).DataEvent(deFieldChange, PtrInt(FField)); |
4313 |
> |
FHasWritten := true; |
4314 |
> |
{ TIBCustomDataSet(FField.DataSet).DataEvent(deFieldChange, PtrInt(FField)); |
4315 |
> |
Removed as this caused a seek to beginning of the blob stream thus corrupting |
4316 |
> |
the blob stream. Moved to the destructor i.e. called after blob written} |
4317 |
|
end; |
4318 |
|
|
4319 |
|
{ TIBGenerator } |