From e0bf42adb040b0834e393a82993fef64791c4415 Mon Sep 17 00:00:00 2001 From: zueuk Date: Sat, 18 Mar 2006 18:07:02 +0000 Subject: [PATCH] fixed an int64 bug, prevented user from starting render if not enough memory --- 2.10/Source/FormRender.pas | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/2.10/Source/FormRender.pas b/2.10/Source/FormRender.pas index 0fb565d..9448620 100644 --- a/2.10/Source/FormRender.pas +++ b/2.10/Source/FormRender.pas @@ -157,10 +157,12 @@ begin GlobalMemoryInfo.dwLength := SizeOf(GlobalMemoryInfo); GlobalMemoryStatus(GlobalMemoryInfo); PhysicalMemory := GlobalMemoryInfo.dwAvailPhys div 1048576; - ApproxMemory := ImageHeight * ImageWidth * Oversample * Oversample * - SizeOf(TBucket) div 1048576; - lblPhysical.Caption := 'Physical memory available: ' + Format('%d', [PhysicalMemory]) + ' Mb'; - lblApproxMem.Caption := 'Approximate memory required: ' + Format('%d', [ApproxMemory]) + ' Mb'; + ApproxMemory := int64(ImageHeight) * int64(ImageWidth) * int64(Oversample * Oversample + * SizeOf(TBucket)) div 1048576; + + 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 else lblPhysical.Font.Color := clWindowText; end; @@ -264,15 +266,17 @@ var begin ImageWidth := StrToInt(cbWidth.text); ImageHeight := StrToInt(cbHeight.text); + if (not chkLimitMem.checked) and (ApproxMemory > PhysicalMemory) then begin Application.MessageBox('You do not have enough memory for this render. Please use memory limiting.', 'Apophysis', 48); -// exit; + exit; end; 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); -// exit; + exit; end; + t := txtFilename.Text; if t = '' then begin @@ -337,7 +341,6 @@ begin Renderer.Terminate; Renderer.WaitFor; Renderer.Free; - Renderer := nil; //? end; if not Assigned(Renderer) then begin @@ -356,7 +359,10 @@ begin oldElapsed:=0; edt:=0; + try + Renderer := TRenderThread.Create; + assert(Renderer <> nil); if chkLimitMem.checked then Renderer.MaxMem := StrToInt(cbMaxMemory.text); Renderer.OnProgress := OnProgress; @@ -367,6 +373,10 @@ begin Renderer.NrThreads := NrTreads; Renderer.Resume; + except + Application.MessageBox('Error while rendering!', 'Apophysis', 48) + end; + // enable screensaver SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, nil, 0); end;