Review of the units in Source/: bugs, memory leaks and performance.
- Date: 2026-11-13.
- Method: static reading of every unit. VCL and RTL behaviour that a finding relies on was checked against the Delphi 12 source:
TCustomListBox.SetSelected, focus removal when a focused control is hidden,TCustomForm.SetActiveControlandTComponentfree notification. Fixed items are covered by a test program (see Tests below). Open items come from reading the code unless noted. - Line numbers: they refer to the working tree after batch 1. Links like
L1535point intoSource/zObjInspector.pasunless another file is named.
Most of the serious problems come from two design flaws, both now fixed:
- The inspector hands out raw
PPropItempointers into a list (FItems) that it frees and rebuilds wholesale (crash #2). - It had no way to find out when the inspected object was freed (crash #1, fixed for
TComponent).
| # | Finding | Status |
|---|---|---|
| 1 | Inspected object freed while inspected | Fixed in 60b4730 for TComponent. Plain TObject relies on the caller. |
| 2 | PPropItem pointers dangle after a rebuild |
Fixed in 90c15b2. |
| 3 | SetPropValue with nothing selected |
Fixed in a2f2928. |
| 8 | UpdateEditControl always calls SetFocus |
Fixed in a2f2928. |
| 7 | Tab key taken from every application | Fixed in 4f05fd6. |
| 5 | TStackEx<T>.Get stack overflow |
Fixed in c26d7c1. |
| 6 | Down arrow in an open dropdown raises EListError |
Fixed in 105f4c7. |
| 10 | Destructor frees its lists before the editor goes | Fixed in fa57bc5. |
| 9 | Setting Font before Parent raises |
Fixed in df704ee. |
| 4 | Popup list freed inside its own handler | Corrected: not reachable today; the real bug is that component-reference dropdowns don't work. |
With #9, every crash in the original list is fixed or corrected. The remaining sections (memory leaks, functional bugs, performance, minor) are open, except for the items marked FIXED in them.
| Functional bug or leak | Status |
|---|---|
| Invalid numbers silently became 0 | Fixed in 41dd078. |
TDateTime, TDate, TTime, Currency and other float types became 0 |
Fixed in 99eb2ca. |
TzObjectHost leaked when the inspector was freed |
Fixed in 0c5c3f8. |
| Batch 1: every remaining leak, 12 small functional bugs, 4 minor items | Fixed (uncommitted); marked "FIXED (batch 1)" below. |
Still open after batch 1:
- Functional:
- component references can't be set (#4);
- one raising getter breaks the whole paint;
- some edits are lost (
FTxtChanged); - non-visual components get blank events (
GetFormRoot); ExpandAlldoesn't stick;- category registrations are wiped;
- sets beyond element 31;
MouseMoveoverwritesHint;- the "non-default" bold.
- Design:
FloatPreferenceis shared by every inspector. - Minor:
GetValueover-reads;IsCircularLinkvisibility. - Performance: all items.
InspectorTests.dpr is a console program that drives a real form and inspector. It currently lives in the session scratchpad and should be moved into the repo.
- Coverage: 253 checks, passing on Win32 and Win64. The batch 1 tests were also run against the previous commit, and each one failed there apart from the single-monitor dropdown sanity check.
PoisonMM.pas: a test-only memory manager that is the first unit in the program'suses.- It fills every freed block with
$80and never reuses it, so any use-after-free becomes an access violation at$80808080. - Without it, FastMM hands a freed
TPropItemstraight back for the next record of the same size, so a dangling pointer usually reads a valid (wrong) record and nothing crashes.
- It fills every freed block with
- Exceptions: exceptions raised inside message handlers go to an
Application.OnExceptionsink and count as failures (unless a test declares it expects one), so a run never blocks on a dialog.
Was:
SetComponentstored a rawTObject, and nothing usedFreeNotificationor overrodeNotification. When the inspected component was freed, or a component that an expanded row points to throughTPropItem.Instance, the next paint calledProp.GetValueon freed memory (L1259).- Freed addresses also get reused: setting
Componentto a new object at the address of the freed one was ignored bySetComponent'sValue <> FComponenttest.
Fix (L1833 to ZCMRebuildItems at L1930):
- Watching: the inspector calls
FreeNotificationon the root component, eachTzObjectHostmember and every component reached through a property (PopupMenu,Images,Action...). This list is rebuilt by everyUpdateItems. - Root freed:
Componentbecomes nil and the list is cleared immediately (L1869). - Nested or hosted component freed: the items are cleared immediately and rebuilt from a posted
ZCM_REBUILDITEMSmessage.- It can't rebuild immediately:
Notificationruns inside the dying component's destructor, after its descendant destructors have run. - Components that reference it may not have been notified yet, so
Button.PopupMenucan still return the dying menu. - A hosted object that is freed is also removed from the host with the new
TzObjectHost.RemoveObject.
- It can't rebuild immediately:
- Editor: before the items are dropped, the editor discards uncommitted text and its item pointer (
DetachEditor,TzPropInspEdit.Detach). Committing is not safe here, because the target may be part-way through its destructor. - Not undone:
RemoveFreeNotificationis deliberately never called. It removes the whole link between the two components, so it would also cut a link the VCL set up for itself (for exampleInspector.PopupMenu := X). Old links clean themselves up when either side is freed, andNotificationignores components that are no longer watched. - Removed vs freed: a component that's only removed from its owner, not freed, is left alone (the handler checks
csDestroying).
Still open:
- Plain
TObjectrelies on the caller. On Win32/Win64 there's no destruction callback, and[weak]only works for interface references. Detecting it would mean patching the class's VMT, which affects the whole process and was rejected. Whoever frees a plain object must first setComponent := nil, or callRemoveObjecton the host. - A nested plain object replaced by a setter is still a use-after-free.
TPicture.SetGraphicandTPicture.LoadFromFilefree the old graphic, but the rows under an expandedPicture.Graphicstill point at it. Either readInstancefrom the parent item each time it's needed (checking the class matchesProp.Parent), or run theItemNeedUpdatecheck before painting.
Was:
UpdateItemsandComponentChangedfreed every record withFItems.Clear, while the editor'sFPropItem, the popup list'sFPropItem, an open dialog'sPropItemandFVisibleItemsstill pointed at them.UpdateEditControlthen hid the editor, and the VCL moves focus away from a hidden control immediately (CMVisibleChanged->RemoveFocus->SetActiveControl(nil)). That ranWMKILLFOCUS->DoSetValueFromEditon the freed record whenever the editor held uncommitted text.- It was reachable through
UpdateProperties,CollapseAll,ExpandAll,ExpandItemor aComponentchange when called from a popup menu, a shortcut or a timer, because none of those take focus. - The +/- click that rebuilds in
MouseDownleft the editor attached to a freed record.
Fix:
UpdateItems(L1788) now commits the editor's pending text while the items are still valid (CommitEditor, L3837), then detaches the editor and clearsFVisibleItemsbefore freeing the items. Callers re-attach the editor throughUpdateEditControl.- If the commit itself rebuilds the items (a class property value), that inner rebuild finishes before the outer one starts.
- Text that's rejected (an invalid value, or the setter raises) is reported with
Application.HandleException. The text is then dropped and the rebuild the caller asked for still happens.
SetComponent(L1544) commits pending text to the previous component before switching.ComponentChanged(L1517) detaches the editor before clearing the items.MouseDown's +/- rebuild callsUpdateProperties, so the editor is re-attached (L3161).ShowModalDialog(L4207) tracks the open dialog, so a rebuild nils aTzInspDialog'sPropItem. After the dialog closes it continues with the re-attached item, or skips setting the value if the item no longer exists. It now uses try/finally.- Docs:
ItemsandVisibleItemsare documented as freed by every rebuild: keep theQualifiedName, not the pointer.
Behaviour to be aware of: pending text is committed before a rebuild, as the old code intended through WM_KILLFOCUS. So a timer that calls UpdateProperties while the user is typing applies the half-typed text and resets the editor.
Still open: an event handler that rebuilds the items while the inspector is inside one of its own loops is not protected. For example:
KeyDown's search loop holdsLSelectedItemacrossDoSelectCaret->SelectItem->OnSelectItem(L3087).SelectItemreadsFVisibleItems[Index]again after callingOnSelectItem(L3576).
Was: DoSetValue always calls FPropInspEdit.UpdateEditText (L2915), which dereferenced FPropItem without checking it. FPropItem is nil until a value row is selected, and it is also nil while a category row is selected. It was an access violation reading address $24 (the offset of FQName).
Fix: UpdateEditText returns when there's no item (L4264).
Correction: the original review said the popup list is freed inside its own OnMouseDown when a component reference is picked from it. A test probe showed that path isn't reachable today.
PropInfoChangedmakes the editor read-only for every class property (L4136).DoSetValueFromListreturns early whenReadOnlyis set (L4005).
The real bug:
- The dropdown for
PopupMenu,Images,Actionand similar properties lists the form's components, but clicking one does nothing. Verified: clickingProbeMenu2leftButton.PopupMenunil. - Typing a name does nothing either, and neither does deleting the text: the editor is read-only, so a reference can't be changed or cleared at all. (An earlier version of this review said deleting the text cleared it; it doesn't.)
Fixing it makes the original crash reachable, so the two have to be fixed together:
- The chain is
ListBoxMouseDown(L4316) ->DoSetValueFromList->DoSetValue->UpdateProperties(class property) ->UpdateEditControl->PropInfoChanged->InitList->FreeAndNil(FList)(L4288-4289). That frees the list while itsWMLButtonDownis still running. - Defer the list re-creation, or don't recreate the list when re-attaching to the same
QualifiedName. DoSetValuemust also clear the editor's pending-text flag (FTxtChanged) for the item being set. Otherwise theCommitEditorcall in the rebuild that follows would overwrite the list choice with whatever had been typed.
Was:
TStackEx<T>.GetreadItems[Index], andItemsisTStackEx's own property, backed byGet.TzCanvasStack.Clearcalls it whenever the stack isn't empty (zCanvasStack.pas:90-95).Clearis called fromInvalidate(L1430).- The stack was left non-empty by any exception during paint, because Push/Pop had no try/finally. So a property getter that raised was followed by a stack overflow on the next
Invalidate. - In the tests, the old
Peek(0)killed the process outright; the overflow could not be caught.
Fix:
GetreadsList[Index](zCanvasStack.pas:225-228).- All five Push/Pop pairs are in try/finally:
PaintHeader(L2217), thePaintrow loop (L2465-2469),PaintCategory(L3308),PaintItemValue(L3540) andPaintValue(L5055-5081).
Still open:
- A property getter that raises still makes the whole paint fail. It does so every time the inspector paints, which shows an error dialog for each
WM_PAINT; see Functional bugs. TzCanvasStack.Destroydoesn't free leftover objects; see Memory leaks.- Replacing the canvas stack altogether is still worthwhile for performance; see the performance section.
Was: TzPropInspEdit.WMKEYDOWN limited the list index by the inspector's VisiblePropCount instead of FList.Items.Count.
- Open a Boolean dropdown, select True, press Down:
FList.Selected[2]raisedEListError("List index out of bounds (2). TzPopupListBox range is 0..1"). - In long lists, such as colours, you couldn't arrow past row
VisiblePropCount - 1.
Fix: Down is clamped to the dropdown's item count while the dropdown is open, and to the inspector's rows otherwise (L4437-4441, in WMKEYDOWN at L4393).
Was:
- To make Tab start the type-to-search mode, the editor registered a system-wide
RegisterHotKey(Handle, 0, 0, VK_TAB)whenever it got focus, and unregistered it on the last line of itsWMKILLFOCUS. DoSetValueFromEditruns earlier in that handler and can raise, for example on non-matching enum text (L4081) or when the setter throws.- So typing "xyz" into an enum and pressing Alt+Tab left Tab swallowed in every application.
- The next
RegisterHotKeyfor the same keystroke then failed and setFUnRegisterKeys := False, so the hotkey was never released until the window was destroyed. - Even when nothing went wrong, plain Tab was registered system-wide for as long as the editor had focus.
Fix:
- No global hotkey:
RegisterKeys,UnRegisterKeys,WMHotKeyand theUnregisterHotKeyinWM_DESTROYare removed (they wereprotected; nothing outside the unit should have called them). - Tab claimed locally: the editor answers
CM_WANTSPECIALKEYfor plain Tab (L4503). That is how a VCL control keeps a key out of the form's dialog navigation. - Search started from the editor:
WMKEYDOWNhandlesVK_TABby starting the search, exactly asWMHotKeydid (L4410).WMCHARswallows the tab character that follows (L4346).
Behaviour kept:
- Shift+Tab and Ctrl+Tab still move between controls.
- With
AllowSearchoff, Tab moves between controls. - In search mode Tab moves to the next control, which is also what the old code actually did. Its "back to the editor" branch only ran when the hotkey had got stuck.
Still open: WMKILLFOCUS still lets the DoSetValueFromEdit exception escape, so rejected text shows an error dialog while focus is moving to another control or application. It no longer has any effect outside the application.
Was: whenever a row was selected, every UpdateEditControl called FPropInspEdit.SetFocus, so Component :=, UpdateProperties, ExpandAll and the deferred rebuild from #1 all behaved badly:
- They raised
EInvalidOperation("Cannot focus a disabled or invisible window") when the inspector couldn't take focus, for example on a hidden tab. - Otherwise they stole focus from whatever control had it.
Fix (UpdateEditControl, L3760):
- When focus moves: the editor takes focus only when focus is already inside the inspector (
FocusIsInside, L3854). That means the inspector, its editor or its dropdown list. Clicks (MouseDownfocuses the inspector first) and keyboard navigation in the editor keep working as before. - Restoring focus after a rebuild: a rebuild hides a focused editor before
UpdateEditControlruns, which moves focus to the form.DetachEditor(L3871) records that the editor had focus, andUpdateEditControlrestores it, but only if focus is still on the form and no other control has taken it since. CanFocusguard:SetFocusis also guarded byCanFocus(L3820-3821).
Behaviour change: calling SelectItem from code no longer moves focus into the inspector. Call Inspector.SetFocus first if that is wanted.
Was: CMFONTCHANGED and CMParentFontChanged measured the row height with Canvas.TextHeight, which forces the control's window handle.
- Creating that handle needs a parent window, so both of these raised
EInvalidOperation("Control ... has no parent window"):- setting
FontbeforeParent; - building a UI bottom-up, because
InsertControlsendsCM_PARENTFONTCHANGED. For example, parenting the inspector to a panel that wasn't parented yet.
- setting
- The row height also kept its old value, because the exception stopped
FItemHeightbeing set.
Fix: the row height is measured with a screen DC and the inspector's font (MeasureItemHeight, L2345). That needs no window handle and gives the same result as Canvas.TextHeight.
Was: TzObjInspectorBase.Destroy freed all its lists before calling inherited.
TWinControl.Destroythen callsRemoveFocus, which sentWM_KILLFOCUSto a focused editor. The editor then read the freedFItems/FDefPropValuewhile committing its pending text.- Freeing the inspector while editing (for example from a keyboard shortcut or a toolbar button, neither of which takes focus) raised an access violation; in the tests it read
$80808080.
Fix (L1356):
- Editor first: the destructor calls
DetachEditor, which drops the editor's pointers and moves focus out of it while everything is still valid. - Lists last: they are freed after
inherited, so the focus removal, window destruction and child-control destruction inTWinControl.Destroycan't reach freed state.
Behaviour to be aware of: text typed into the editor and not yet committed is discarded when the inspector is freed, because the inspected component may be part of the same teardown. A normal form close still commits it, because the form deactivates (and the editor loses focus) before anything is destroyed.
All memory leaks are fixed.
TzObjectHost- FIXED in 0c5c3f8.- Was: the inspector freed a host when it was replaced (L1547) or set to nil, but not in its destructor. Using the demo's "Multi components" button and then closing the app leaked it.
- Fix: the destructor frees a host still assigned to
Component(L1391), afterinheritedlike the other owned objects. The ownership rule (aTzObjectHostis owned, anything else is not) is documented on theComponentproperty.
SetFloatPreference- FIXED (batch 1).- Was: it stored the caller's object in the class var (L187) instead of copying it. The original object leaked, and the class destructor (L4534) freed the caller's object; against the old code the tests end in runtime error 216 at shutdown.
- Fix: it copies the settings with
Assign(L2004). - Still open:
FloatPreferenceis a class var, so every inspector in the process shares it.
UpdateItems- FIXED (batch 1):LCategoryis now freed in a try/finally (L1801), so a getter that raises no longer leaks it.FItemsis still left half built in that case.ShowModalDialog- FIXED in 90c15b2 (it now uses try/finally).TzCanvasStack.Destroy- FIXED (batch 1): it callsClearfirst, which frees any brush, font and pen still saved (zCanvasStack.pas:84).- Dialogs - FIXED (batch 1):
TStringsDialog.InitDialog(zStringsDialog.pas:82) andTGraphicDialog.InitDialog(zGraphicDialog.pas:103) no longer leak whenPropItemis set twice.
- Component references can't be set from the dropdown or by typing a name. See #4.
- One raising getter breaks the whole paint.
PaintValueandPaintItemread property values directly, so an exception from any getter escapesPaint. In a realWM_PAINTthat is an error dialog, then a repaint, then the same error, and none of the other rows are drawn. Getters that raise are common withObjectVisibility = mvPublic(plain objects), and for some VCL properties in some states. The Delphi IDE instead shows the exception message as that row's value. - Invalid numbers silently became 0 - FIXED in 41dd078.
- Was:
StrToValueignored the results ofTryStrToFloat/TryStrToInt64, soabcset a number to 0.- Values outside the type's range reached the setter, which truncated them: 300 into a Byte stored 44.
Int64andUInt64properties were never parsed at all, becauseTRttiInt64Typeis notIsOrdinal. Any text typed into them set them to 0. This wasn't in the original review; the tests found it.
- Fix (
StrToValue, L5110):- Text that isn't a number, or is outside the property type's range, raises
InvalidPropValueError, the same as non-matching enum text already did. - The new
TryParseOrdinal(L5202) works out each type's real range, Cardinal and UInt64 included. It accepts hex as a bit pattern for signed types, so$FF00000Ftyped into aTColoris still clBtnFace; that's also howColorToStringshows a system colour that has no name. - The raise lives in
RaiseInvalidValue(L5261), because a generic method declared in the interface can't use the implementation's exception class.
- Text that isn't a number, or is outside the property type's range, raises
- Unchanged:
- Empty text still sets a number to 0 (an explicit branch in
DoSetValueFromEdit, L4041). - Values are rejected with an error rather than corrected.
- Empty text still sets a number to 0 (an explicit branch in
- Was:
TDateTime,TDate,TTime,Currencyand other float types were set to 0 by any text - FIXED in 99eb2ca. Found while testing the invalid-numbers fix.- Was:
- These types displayed correctly, but
GetValueTypeonly recognises the exactSingle/Double/Extendedtype infos (L4929). - Every other float type, including distinct types such as
TMeasure = type Double, fell through to the ordinal path. ThereStrToValuereturned 0, andGetValuewrote it through the sharedTValuestorage. - Typing
4/03/2021into aTDateTimestored 30/12/1899,99into aCurrencystored 0, and invalid text was written as 0 too.
- These types displayed correctly, but
- Fix:
DoSetValueFromEditsends any othertkFloatproperty to the newStrToFloatValue(L4103, L5266).StrToFloatValueparses with the function that matches howTValue.ToStringdisplays the type:TryStrToDate,TryStrToTimeorTryStrToDateTimefor the date types;TryStrToCurrforCurrency;TryStrToInt64forComp;TryStrToFloatotherwise.- It builds the value with the property's own type info, and rejects text it can't parse with
InvalidPropValueError. Single,DoubleandExtendedkeep their existing path.
- Was:
- Some edits are lost. Edits made with Backspace, Delete or context-menu paste never set
FTxtChanged: it is only set inWMCHAR, and thevkBackbranch exits before setting it (L4365-4369). UseChange/EN_CHANGEinstead. This also affects the commit-before-rebuild from #2. - Text was always black - FIXED (batch 1).
Font.Color := GetSysColor(clWindowText)passed aTColor($FF000008) as a system colour index, soGetSysColorreturned 0, which was unreadable on dark or high-contrast themes. It's nowclWindowText(L4146). - Function-type events never listed handlers - FIXED (batch 1).
PropSameMethodTypecomparedLPType.ReturnType.HandlewithAMethod.Handleinstead ofAMethod.ReturnType.Handle(L901), so events such asOnHelpgot no handlers. - Non-visual components get blank events and empty dropdowns.
GetFormRoot(L1035) only resolvesTControl, soTMenuItem,TTimerandTDataSetshow blank event names and empty method/component dropdowns. The demo shows it withPopupItemTest1when events are enabled. WalkTComponent.Ownerinstead. ExpandAlldoesn't stick. It (L2919) records nothing inFExpandedList/FSaveVisibleItems, so the tree collapses on the next refresh.- A host forced category sorting - FIXED (batch 1). Assigning a
TzObjectHostsetFSortByCategory := Truepermanently, so the next normal component was grouped too.UpdateItemsnow uses a local flag (L1799), andSortByCategoryis left alone. - Category registrations are wiped.
ComponentChanged(L1517) clears everyRegisterPropertyInCategoryregistration on each component change. - Search couldn't reach the last row - FIXED (batch 1):
Index < FVisibleItems.Count - 1is now< FVisibleItems.Count(L2878), so Tab on the last row starts searching. - Sets:
- WideChar values above #255 were mangled - FIXED (batch 1).
vtCharwrote onlyFAsUByte, so aPasswordCharof '●' (U+25CF) became 'Ï' (U+00CF). It now writesFAsUWordfor WideChar (L4753). - Dropdown height was wrong on multiple monitors - FIXED (batch 1).
- Was:
ShowListsized againstScreen.Height, and the height went negative on a monitor below the primary. - Fix: it now fits the work area of the monitor the list opens on (L4182).
- Test coverage: the test only checks that the list fits on a single monitor; a multi-monitor setup couldn't be tested here.
- Was:
SetSplitterPosdidn't repaint or move the editor - FIXED (batch 1). Setting it from code (not while loading) now calls a new virtualSplitterMoved(L2134). The inspector overrides it to repaint and reposition the editor (L3754).MouseMoveoverwrites the control's ownHint/ShowHint(L3256-3279).- Wrong indentation for some objects - FIXED (batch 1).
- Was:
GetItemOrdercounted the dots in the item's qualified name. That name embedsObject.ToStringand category names, so aToStringor category name containing '.' shifted the whole tree. - Fix: it now uses the item's depth below its top-level item, plus one inside a category (L1404).
- Still open: qualified names themselves still contain
ToStringand category names.
- Was:
TzInspDialogwas declared twice - FIXED (batch 1). Dialogs derived from thezObjInspDialogscopy failed theInheritsFromcheck and raisedDialogDerivedError.zObjInspDialogs.TzInspDialogis now an alias of the real class (zObjInspDialogs.pas:35), so existing code still compiles.VKeyToStrmangled non-Latin-1 input - FIXED (batch 1). It usedToAsciiinto a WideChar buffer. It now usesToUnicode, with the flag that leaves dead-key state alone on Windows 10 1607 and later (zUtils.pas:57). Not covered by a test.MouseDowncould index with -1 - FIXED (batch 1): it now exits when the rebuilt item is no longer visible (L3145). Not covered by a test.- "Non-default" bold is misleading. It means "changed since this row was first selected" (L4277), not the RTTI
defaultvalue.
- Every refresh rebuilds the whole object graph eagerly.
UpdateItems(L1569) enumerates every nested class property, including component references (PopupMenu,ActiveControl,Images...), and calls every getter. It runs on everyUpdateProperties: each class-property edit,CollapseAll,ExpandItem,FloatPreferencechanges. Enumerate children only when a node is expanded. - Tree navigation is O(n).
TPropItem.CountandItems[](L1098-1244) each doFItems.IndexOf(@Self)plus a scan, andItems[]allocates aTListon every call.UpdateVisibleItemsevaluatesPItem.Count > 0for every item before the cheapFIsSettingComponenttest (L1985), so every refresh is O(n²).- Expand/collapse is O(k·n).
- Store parent/child indices (or a child list) while building.
- Linear string lookups inside those loops.
TList<string>.Containsis used onFExpandedList,FSaveVisibleItemsandFCircularLinkProps. UseTDictionary<string, Boolean>. - Paint does RTTI work for every row.
GetValueType, which calls the property getter, runs about 5 times per row viaExtraRect/ValueTextRect/HasButton.HasChild(L1142) creates aTRttiContextand runsGetUsedPropertiesfor every class-typed row on every paint (L974-990).ValueNameis computed 2-3 times per row.GetFirstItemIndex(L2387) makes aGetScrollInfocall for every rect.- Compute the value, type and name once per row per paint.
GetUsedPropertiesis O(p²) (L5432-5462) and grows its array one element at a time withSetLength.TzCanvasStackcreates and frees a TBrush, TFont and TPen per push, about 3 pushes per row per paint, plusCanvas.Refresh.SaveDC/RestoreDC, or saving just the 4 properties that are actually changed, is cheaper and removes crash #5.InitListrecreates the popup listbox whenever the editor is attached to an item (L4282). It forces window creation and repopulation (about 250 items for ShortCut) even if the list is never dropped down. Since the #2 fix this also happens after every rebuild, because the editor is always detached first. Create it lazily inShowList.- Smaller:
DrawHorzDotLine(zUtils.pas:74-84) does one MoveTo/LineTo per 2 pixels. Use aPS_ALTERNATEpen.GetSelectedItemdoes a linearSameTextscan (L3019).Invalidateinvalidates twice (L1429, L1432).
TPropItem.Empty- FIXED (batch 1): it usedZeroMemoryon a record that contains a string, and now usesDefault(TPropItem)(L1082).GetValue(const Value)over-reads. It reads 8 bytes through the untyped parameter regardless of the caller's variable size (Boolean, TColor, TObject on Win32) (L4787-4790). It only works becauseAsOrdinallater reads the low bytes.IsCircularLinkchecks visibility againstLComponentinstead of the object being inspected (L1627).UpdateButton- FIXED (batch 1): it tested> VisiblePropCountwhere it should test>=(L4250).TzCanvasStack.Create(Collection)- FIXED (batch 1): it left the two internal stacks unbalanced, soPeekraised "Unbalanced stack". It now pushes each canvas (zCanvasStack.pas:72).FloatConv_impl.inc- FIXED (batch 1): it indexedStr[1]without checking for an empty string, so whitespace-only input raised an access violation. It now checks first (L46, L90). It is dormant anyway, becauseCUSTOMFLOATCONVisn't defined in the packages. When it is defined,MyFormatFloatalso compiles aTRegExon every call (still open).- Unused code:
zBase.TzToolWindow/TzPopupWindowaren't used by the library, andzObjInspDialogsis now only an alias kept for compatibility.