View Issue Details

IDProjectCategoryView StatusLast Update
0021733LazarusLCLpublic2012-04-14 10:35
ReporterDavid Jenkins Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilitysometimes
Status resolvedResolutionfixed 
Product Version0.9.30.5 (SVN) 
Summary0021733: GetTopItem and GetVisibleRowCount of TCustomListView crash when called with no handle allocated
DescriptionOur code will sometimes call TCustomListView.GetTopItem and TCustomListVIew.GetVisibleRowCount before a before a widget handle is allocated which results in bad default values or crashes.

Suggested fix is to add HandleAllocated checks to the branches or those functions that that set default values.

Patch against rev 36681 is attached
TagsNo tags attached.
Fixed in Revision36762
LazTarget-
WidgetsetCarbon
Attached Files

Activities

2012-04-13 16:44

 

customlistview.inc.patch (737 bytes)   
--- /Users/djenkins/laz-changes/13896/customlistview.inc	2012-04-09 17:32:21.000000000 
+++ /Users/djenkins/laz-changes/13896/customlistview.inc.ss	2012-04-09 17:33:24.000000000 
@@ -1189,7 +1189,7 @@
 var
   idx: Integer;
 begin
-  if ViewStyle in [vsSmallIcon, vsIcon]
+  if (ViewStyle in [vsSmallIcon, vsIcon]) or (not HandleAllocated)
   then idx := -1
   else idx := TWSCustomListViewClass(WidgetSetClass).GetTopItem(Self);
   if idx = -1
@@ -1214,7 +1214,7 @@
 
 function TCustomListView.GetVisibleRowCount: Integer;
 begin
-  if ViewStyle in [vsReport, vsList]
+  if (ViewStyle in [vsReport, vsList]) and HandleAllocated
   then Result := TWSCustomListViewClass(WidgetSetClass).GetVisibleRowCount(Self)
   else Result := 0;
 end;
customlistview.inc.patch (737 bytes)   

Zeljan Rikalo

2012-04-14 10:14

developer   ~0058571

WSGetTopItem and WSGetVisibleRowCount should check that and return proper result.
LCL isn't good place for that.In this case, carbon part should be fixed.

Zeljan Rikalo

2012-04-14 10:35

developer   ~0058577

Please test and close if ok.
NOTE: All mentioned routines already checks if handle is allocated inside carbon ws. I've changed GetTopItem result to -1 inside carbon, and fixed potentially "no result" with GetViewOrigin and GetBoundingRect.

Issue History

Date Modified Username Field Change
2012-04-13 16:44 David Jenkins New Issue
2012-04-13 16:44 David Jenkins File Added: customlistview.inc.patch
2012-04-13 16:44 David Jenkins Widgetset => Carbon
2012-04-14 10:14 Zeljan Rikalo LazTarget => -
2012-04-14 10:14 Zeljan Rikalo Note Added: 0058571
2012-04-14 10:14 Zeljan Rikalo Status new => feedback
2012-04-14 10:35 Zeljan Rikalo Fixed in Revision => 36762
2012-04-14 10:35 Zeljan Rikalo Status feedback => resolved
2012-04-14 10:35 Zeljan Rikalo Resolution open => fixed
2012-04-14 10:35 Zeljan Rikalo Assigned To => Zeljan Rikalo
2012-04-14 10:35 Zeljan Rikalo Note Added: 0058577