fixed an int64 bug,

prevented user from starting render if not enough memory
This commit is contained in:
zueuk 2006-03-18 18:07:02 +00:00
parent ff2002f7d2
commit e0bf42adb0

View File

@ -157,10 +157,12 @@ begin
GlobalMemoryInfo.dwLength := SizeOf(GlobalMemoryInfo); GlobalMemoryInfo.dwLength := SizeOf(GlobalMemoryInfo);
GlobalMemoryStatus(GlobalMemoryInfo); GlobalMemoryStatus(GlobalMemoryInfo);
PhysicalMemory := GlobalMemoryInfo.dwAvailPhys div 1048576; PhysicalMemory := GlobalMemoryInfo.dwAvailPhys div 1048576;
ApproxMemory := ImageHeight * ImageWidth * Oversample * Oversample * ApproxMemory := int64(ImageHeight) * int64(ImageWidth) * int64(Oversample * Oversample
SizeOf(TBucket) div 1048576; * SizeOf(TBucket)) div 1048576;
lblPhysical.Caption := 'Physical memory available: ' + Format('%d', [PhysicalMemory]) + ' Mb';
lblApproxMem.Caption := 'Approximate memory required: ' + Format('%d', [ApproxMemory]) + ' Mb'; lblPhysical.Caption := 'Physical memory available: ' + Format('%u', [PhysicalMemory]) + ' Mb';
lblApproxMem.Caption := 'Approximate memory required: ' + Format('%u', [ApproxMemory]) + ' Mb';
if ApproxMemory > PhysicalMemory then lblPhysical.Font.Color := clRed if ApproxMemory > PhysicalMemory then lblPhysical.Font.Color := clRed
else lblPhysical.Font.Color := clWindowText; else lblPhysical.Font.Color := clWindowText;
end; end;
@ -264,15 +266,17 @@ var
begin begin
ImageWidth := StrToInt(cbWidth.text); ImageWidth := StrToInt(cbWidth.text);
ImageHeight := StrToInt(cbHeight.text); ImageHeight := StrToInt(cbHeight.text);
if (not chkLimitMem.checked) and (ApproxMemory > PhysicalMemory) then if (not chkLimitMem.checked) and (ApproxMemory > PhysicalMemory) then
begin begin
Application.MessageBox('You do not have enough memory for this render. Please use memory limiting.', 'Apophysis', 48); Application.MessageBox('You do not have enough memory for this render. Please use memory limiting.', 'Apophysis', 48);
// exit; exit;
end; end;
if chkLimitMem.checked and (PhysicalMemory < StrToInt(cbMaxMemory.text)) and (Approxmemory > PhysicalMemory) then begin if chkLimitMem.checked and (PhysicalMemory < StrToInt(cbMaxMemory.text)) and (Approxmemory > PhysicalMemory) then begin
Application.MessageBox('You do not have enough memory for this render. Please use a lower Maximum memory setting.', 'Apophysis', 48); Application.MessageBox('You do not have enough memory for this render. Please use a lower Maximum memory setting.', 'Apophysis', 48);
// exit; exit;
end; end;
t := txtFilename.Text; t := txtFilename.Text;
if t = '' then if t = '' then
begin begin
@ -337,7 +341,6 @@ begin
Renderer.Terminate; Renderer.Terminate;
Renderer.WaitFor; Renderer.WaitFor;
Renderer.Free; Renderer.Free;
Renderer := nil; //?
end; end;
if not Assigned(Renderer) then if not Assigned(Renderer) then
begin begin
@ -356,7 +359,10 @@ begin
oldElapsed:=0; oldElapsed:=0;
edt:=0; edt:=0;
try
Renderer := TRenderThread.Create; Renderer := TRenderThread.Create;
assert(Renderer <> nil);
if chkLimitMem.checked then if chkLimitMem.checked then
Renderer.MaxMem := StrToInt(cbMaxMemory.text); Renderer.MaxMem := StrToInt(cbMaxMemory.text);
Renderer.OnProgress := OnProgress; Renderer.OnProgress := OnProgress;
@ -367,6 +373,10 @@ begin
Renderer.NrThreads := NrTreads; Renderer.NrThreads := NrTreads;
Renderer.Resume; Renderer.Resume;
except
Application.MessageBox('Error while rendering!', 'Apophysis', 48)
end;
// enable screensaver // enable screensaver
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, nil, 0); SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, nil, 0);
end; end;