2 small fixes

53 views
Skip to first unread message

Dmitri

unread,
May 7, 2014, 4:40:56 AM5/7/14
to virtual-...@googlegroups.com
Recently I got many user reports about EOutOfResources happened at arbitrary time. Deep investigation showed that this exception is raised on GDIError. The error was returned by GDI in attempt to set size of a bitmap to very very large value (some million pixels). This bitmap is used in VCL Styles engine (StyleAPI.inc), and its size was suggested by TVclStyleScrollBarsHook hook established in VirtualTrees.pas.
I'm not sure why Delphi is silent about this problem, but it's clear that not all code branches in TVclStyleScrollBarsHook.GetHorzScrollBarSliderRect and TVclStyleScrollBarsHook.GetVertScrollBarSliderRect assign values to the returning result, leaving TRect unintialized if scrollbar is not visible or not enabled.
Fix is below:
 
function TVclStyleScrollBarsHook.GetHorzScrollBarSliderRect: TRect;
var
  P: TPoint;
  BarInfo: TScrollBarInfo;
begin
  if FHorzScrollBarWindow.Visible and FHorzScrollBarWindow.Enabled then
  begin
...
  end
+  else
+   Result := TRect.Empty;
end;
 
 
function TVclStyleScrollBarsHook.GetVertScrollBarSliderRect: TRect;
var
  P: TPoint;
  BarInfo: TScrollBarInfo;
begin
  if FVertScrollBarWindow.Visible and FVertScrollBarWindow.Enabled then
  begin
...
  end
+  else
+   Result := TRect.Empty;
end;
 

Joachim Marder

unread,
May 7, 2014, 3:35:43 PM5/7/14
to virtual-...@googlegroups.com
Thanks Dmitri, I've just committed your patch.


--
You received this message because you are subscribed to the Google Groups "Virtual Treeview" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virtual-treevi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dmitri

unread,
May 8, 2014, 5:28:26 AM5/8/14
to virtual-...@googlegroups.com
Seems with this patch I broke compatibilty with earlier versions of Delphi. TRect.Empty is available only in recent Delphi libraries, while earlier ones do not have this method. Perhaps Result := Rect(0, 0, 0, 0) will be more appropriate.
BTW, what's the lowest supported/maintained version of Delphi? 7?
 

Joachim Marder

unread,
May 8, 2014, 10:16:53 AM5/8/14
to virtual-...@googlegroups.com
I noticed that and adapted your code before the commit.

We currently support Delphi 7 and higher. But I would like to make a (stable) branch for Delphi 7-2007 and in the trunk I would like to drop support for non-Unicode versions of Delphi.


2014-05-08 11:28 GMT+02:00 Dmitri <ddmi...@gmail.com>:
Seems with this patch I broke compatibilty with earlier versions of Delphi. TRect.Empty is available only in recent Delphi libraries, while earlier ones do not have this method. Perhaps Result := Rect(0, 0, 0, 0) will be more appropriate.
BTW, what's the lowest supported/maintained version of Delphi? 7?
 

--
Reply all
Reply to author
Forward
0 new messages