Skip to content

About

VCL Virtual String Tree for RadStudio 10.4+

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Virtual TreeView 8.3 - Optimized Edition

High-performance virtual tree control for Delphi / RAD Studio. This fork includes deep code audit, critical bug fixes, performance optimizations, and modernization.

Supported: RAD Studio 10.4 Sydney and higher (Delphi & C++ Builder) License: MPL 1.1 / LGPL 2.1 with static linking exception


What's New in This Edition

Critical Bug Fixes (Phase 1-2)

  • Fixed infinite recursion in GetSystemMetrics (FMX)
  • Fixed race condition in worker thread singleton
  • Fixed HTML/RTF injection in export (XSS prevention)
  • Fixed pixel offset in bmMasterAlpha alpha blending
  • Fixed TThread.Queue use-after-free in validation
  • Fixed GlobalAlloc null-check (5 locations)
  • Fixed StgMediumIncRef stale data on error
  • Replaced Sleep(1) busy-wait with MsgWaitForMultipleObjects

Performance Optimizations (Phase 3, 8)

  • Theme handle caching (eliminates OpenThemeData/CloseThemeData per cell)
  • Node bitmap reuse (eliminates TBitmap.Create/Free per paint cycle)
  • SSE2: 2 pixels per iteration in bmConstantAlpha (~2x speedup on x64)
  • SystemParametersInfo caching in mouse wheel handler
  • ScrollBar bitmap caching in style hooks
  • O(n) format array growth instead of O(n^2)
  • Iterative DeleteChildren (no stack overflow at depth 10,000+)
  • Free-list node recycling (reuse freed memory blocks)
  • Non-blocking Animate (UI responsive during expand/collapse)
  • HandleHotTrack early-exit when hot tracking disabled
  • Font cache (FFontCacheValid) skips redundant Canvas.Font.Assign

Code Quality (Phase 4, 7)

  • Extracted methods from 800-line WMKeyDown, 600-line PaintTree, 480-line HandleMessage
  • Unified duplicate MergeAscending/MergeDescending into single MergeNodes
  • Replaced TWriterHack with System.Rtti
  • Eliminated dangerous with blocks (11 instances)
  • Added const to 22 methods with TPoint/TRect parameters

Modernization (Phase 5, 7)

  • MMX replaced with SSE2 in all 32-bit alpha blending (removed EMMS)
  • Fixed pre-existing SSE2 alpha extraction bug (PUNPCKHWD -> PSHUFLW)
  • TList -> TObjectList<T> in clipboard with OwnsObjects
  • DPI-aware DrawExpandArrow with ScaledPixels
  • AnsiQuotedStr -> string.QuotedString
  • Enum validation on stream load (13 points)
  • GUID string literals, DupeString, inline getters, scoped {$WARN}
  • Screen.PixelsPerInch -> CurrentPPI for per-monitor DPI

Architecture (Phase 6)

  • TVirtualNode cache-line optimization: hot fields in first 48 bytes, {$ALIGN 8}, same SizeOf
  • TVirtualDrawTree aligned with TVirtualStringTree (+11 published properties)
  • Typed column enumerator (for Col in Columns do)

Testing

  • 84 tests (77 functional + 7 benchmarks), all passing
  • Covers: accessibility, threading, export, rendering, sorting, keyboard, streaming, SSE2, selection, hot tracking, animation, font cache
  • QPC-based benchmarks with microsecond precision

Installation

See INSTALL.txt for step-by-step instructions.

Quick start:

  1. Open Packages\RAD Studio 10.4+\VirtualTreeView.groupproj
  2. Build All
  3. Install VirtualTreesD*.bpl
  4. Add library paths for Win32 and Win64

Benchmarks (x64, Release)

Operation Time Notes
Create 100K nodes ~28 ms With free-list recycling
Delete 5K deep tree ~50 ms Iterative post-order traversal
Sort 50K nodes ~21 ms MergeSort
Paint 500 nodes x 5 cols ~14 ms Full pipeline with font/theme cache
RTF Export 10K nodes ~11 ms With DupeString tabs
SelectAll 10K nodes ~10 ms NativeUInt-sorted selection
Free-list recycle 10K ~12 ms Add/Delete/Add cycle

Project Structure

Source/          - 25 core library units
Design/          - Design-time IDE registration
Packages/        - Build packages (RAD Studio 10.4+, C++ Builder 10.4-12)
Tests/Aggressive - 84 automated tests + benchmarks
Demos/           - Example applications
Doc/             - Documentation, audit report, progress tracking
Help/            - CHM help file and source
Resources/       - Bitmaps, cursors, icons

Authors

Original authors: Mike Lischke (creator), JAM Software (maintainer since 2014) Optimization & modernization: Platon (2026) - deep audit, 130+ findings, 84 tests

Original repository: JAM-Software/Virtual-TreeView


License

Virtual Treeview is published under a double license:



Virtual TreeView 8.3 - Optimized Edition (RU)

Высокопроизводительный виртуальный tree-контрол для Delphi / RAD Studio. Этот форк включает глубокий аудит кода, исправление критических багов, оптимизацию производительности и модернизацию.

Поддержка: RAD Studio 10.4 Sydney и выше (Delphi & C++ Builder) Лицензия: MPL 1.1 / LGPL 2.1 с исключением для статической линковки


Что нового в этой версии

Критические исправления (Фазы 1-2)

  • Исправлена бесконечная рекурсия в GetSystemMetrics (FMX)
  • Исправлена гонка (race condition) в singleton worker thread
  • Исправлена HTML/RTF-инъекция в экспорте (предотвращение XSS)
  • Исправлено смещение пикселей в bmMasterAlpha
  • Исправлен use-after-free в TThread.Queue при валидации
  • Добавлена проверка GlobalAlloc на null (5 мест)
  • Исправлен StgMediumIncRef — очистка stale data при ошибке
  • Заменён Sleep(1) busy-wait на MsgWaitForMultipleObjects

Оптимизация производительности (Фазы 3, 8)

  • Кэширование theme handles (убраны OpenThemeData/CloseThemeData на каждую ячейку)
  • Переиспользование Node bitmap (убрано создание TBitmap на каждый paint)
  • SSE2: 2 пикселя за итерацию в bmConstantAlpha (~2x ускорение на x64)
  • Кэширование SystemParametersInfo при обработке колеса мыши
  • Кэширование ScrollBar bitmap в style hooks
  • Рост массива форматов O(n) вместо O(n^2)
  • Итеративный DeleteChildren (без переполнения стека на глубине 10,000+)
  • Free-list рециклинг узлов (повторное использование освобождённой памяти)
  • Неблокирующая анимация Animate (UI отзывчив при expand/collapse)
  • Early-exit в HandleHotTrack при отключённом hot tracking
  • Кэш шрифтов (FFontCacheValid) — пропуск лишних Canvas.Font.Assign

Качество кода (Фазы 4, 7)

  • Извлечены методы из 800-строчного WMKeyDown, 600-строчного PaintTree, 480-строчного HandleMessage
  • Объединены дубликаты MergeAscending/MergeDescending в единый MergeNodes
  • TWriterHack заменён на System.Rtti
  • Устранены опасные блоки with (11 экземпляров)
  • Добавлен const к 22 методам с параметрами TPoint/TRect

Модернизация (Фазы 5, 7)

  • MMX заменён на SSE2 во всех 32-битных функциях alpha blending (убран EMMS)
  • Исправлен pre-existing баг SSE2 извлечения альфы (PUNPCKHWD -> PSHUFLW)
  • TList -> TObjectList<T> в clipboard с OwnsObjects
  • DPI-aware DrawExpandArrow с ScaledPixels
  • AnsiQuotedStr -> string.QuotedString
  • Валидация enum при загрузке из потока (13 точек)
  • GUID строковые литералы, DupeString, inline getters, scoped {$WARN}
  • Screen.PixelsPerInch -> CurrentPPI для per-monitor DPI

Архитектура (Фаза 6)

  • Оптимизация TVirtualNode для cache-line: горячие поля в первых 48 байтах, {$ALIGN 8}, без изменения SizeOf
  • TVirtualDrawTree выровнен с TVirtualStringTree (+11 published свойств)
  • Типизированный enumerator для колонок (for Col in Columns do)

Тестирование

  • 84 теста (77 функциональных + 7 бенчмарков), все проходят
  • Покрытие: accessibility, threading, export, rendering, sorting, keyboard, streaming, SSE2, selection, hot tracking, animation, font cache
  • QPC-бенчмарки с микросекундной точностью

Установка

См. INSTALL.txt для пошаговой инструкции.

Быстрый старт:

  1. Откройте Packages\RAD Studio 10.4+\VirtualTreeView.groupproj
  2. Build All
  3. Install VirtualTreesD*.bpl
  4. Добавьте library paths для Win32 и Win64

Авторы

Оригинальные авторы: Mike Lischke (создатель), JAM Software (сопровождение с 2014) Оптимизация и модернизация: Platon (2026) - глубокий аудит, 130+ находок, 84 теста

Оригинальный репозиторий: JAM-Software/Virtual-TreeView


Лицензия

Virtual Treeview опубликован под двойной лицензией:

About

VCL Virtual String Tree for RadStudio 10.4+

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages