所有用Delphi 3的TJpegImage开发过Web
ISAPI程序的人都知道:刚开始程序运行是正确的,但是运行不出几次,程序就会出问题:Web
Server产生页面错误!但是仔细检查自己的程序,发现还是没有问题,到底为什么?
经仔细检查Delphi 3 VCL 的源程序,发现实际上错误发生在Delphi 3的图形处理文件Graphics中,Borland公司的开发人员锁住了BitmapCanvasList但是未解锁,使得程序在多线程的程序中会产生错误。
具体如下:(下面的程序在Delphi
3\Source\VCL\Graphics.pas中)
procedure FreeMemoryContexts;
var
I: Integer;
begin
with BitmapCanvasList.LockList do
begin
try
for I := Count-1 downto 0 do
with TBitmapCanvas(Items[I]) do
if TryLock then
try
FreeContext;
finally
Unlock;
end;
finally
BitmapCanvasList.UnLockList;
end
end;
end;
...
procedure DeselectBitmap(AHandle:
HBITMAP);
var
I: Integer;
begin
if AHandle = 0 then Exit;
with BitmapCanvasList.LockList do
try
for I := Count - 1 downto 0 do
with TBitmapCanvas(Items[I]) do
if (FBitmap <> nil) and
(FBitmap.FImage.FHandle = AHandle) then
FreeContext;
finally
BitmapCanvasList.UnLockList;
end
end;
在以上的程序中红色为补充的程序,桔红色为发生错误的程序。
修改的方法为修改以上的程序,然后编译生成DCU文件,覆盖在Lib中的DCU文件,重新编译你所有用到图形的程序。
|