Skip to content

Engine upgrade - #54

Merged
khumnath merged 9 commits into
mainfrom
engine-upgrade
Jun 23, 2026
Merged

khumnath merged 9 commits into
mainfrom
engine-upgrade

Conversation

@khumnath

Copy link
Copy Markdown
Owner

No description provided.

khumnath added 9 commits June 13, 2026 19:53
- Engine Upgrade: Completely removed the slow JavaScript logic (PanchangaCalculator.js, EventData.js, PreCalculated_Data.js) and migrated all astronomical calculations, events, and data to a native C++ backend for massively improved performance.
- Architecture: Extracted Bikram Sambat date calculations from the monolithic PanchangaCalculator into a dedicated BikramCalendar class (Facade pattern).
- Renaming: Renamed bsmonthdata for better semantic accuracy.
- Testing: Integrated CTest into CMake with JSON baseline verification and --generate flag.
- Developer Experience: Automated compile_commands.json generation for IDE support.
- Documentation: Added Running Tests instructions to READMEs.
- UI/UX & Bug Fixes: Fixed print dialog timing, rounded alpha selector, and bumped version to 2.3.0.
- Cleanup: Fixed misplaced includes and ran code formatting.
- Fixed a boundary error in findAharForBsDate where cross-year date seeking went into unbounded loops or returned incorrect month data.
- Months in early algorithmic years (e.g. BS 998) now calculate precisely without exceeding 32 days.
- Javascript's Date.UTC() automatically interprets years 0-99 as 1900-1999. This broke the calendar when viewing early BS dates that correspond to the 1st century AD.
- Replaced Date.UTC initialization with setUTCFullYear() which treats 2-digit years exactly literally.
When rendering the calendar by AD year (or converting to JS Date objects), the QML JavaScript engine would silently map AD years 0-99 to 1900-1999 because of Date.UTC() behavior. This caused 'Year 1' to incorrectly show data for 1901 (and map back to BS 1957). Fixed by explicitly calling setUTCFullYear() when year is 0-99.
The inner gradients were lacking margins, causing them to draw over the border and mask the rounded corners of the slider tracks.
…g in README

Adds the standard GPLv3 copyright header to all C++ and QML files that were missing it. Also updates the README with a new section clarifying dual licensing for commercial use and referencing the related Web/Android versions.
…matting

* Core & Calculations:
  - Refactored PanchangaCalculator to use a true sunrise-to-sunrise period when finding daily elements (Tithi, Nakshatra, Yoga, Karana).
  - Updated formatAharTime to accurately wrap times (e.g., 24+ hours) based on the next sunrise instead of a hardcoded 24-hour cycle.
  - Enhanced Bikram Sambat date conversions (bikram.cpp/bikram.h) to fix boundary issues and improve AD <-> BS mappings.

* UI & QML:
  - Updated CalendarLogic.qml to correctly process and display the revised daily events data structures.
  - Adjusted PanchangaDetailDialog.qml to render the new sunrise-relative timings accurately.
  - Minor updates to CalendarGrid.qml and DayCell.qml for improved integration.

* Testing:
  - Rewrote tests/test.cpp to systematically validate QDate transitions across different epochs and century boundaries (e.g., Year 1 AD to 2000 AD).
  - Archived old test files to tests/archive/.

* formatting:
  - Massively reformatted src/astronomy.c to standard block structures for better readability and normalized line endings.
  - Updated build_info.conf and version.conf.
This commit addresses all critical, high, medium, and low-severity issues
discovered during the deep codebase analysis, improving application
stability, security, and rendering correctness.

Critical & High Priority Fixes:
- fix(TooltipManager): Resolved a severe memory leak by removing the unused
  `showText` method which was dynamically allocating `QQuickView` instances
  without parenting or cleanup.
- fix(helper): Patched a dangling pointer risk by using `QPointer<QQuickWindow>`
  for safe object tracking.
- fix(AutostartManager): Hardened desktop entry creation against path injection
  vulnerabilities by properly quoting Exec paths and sanitizing filenames.
  Fixed uninitialized `m_autostartKey` usage.
- fix(PanchangaCalculator): Prevented out-of-bounds array access in
  `karanaIdx` by clamping the value to `0 - 59`. Fixed `getEventsForDate`
  to use the passed `tz` instead of the hardcoded default `5.75`.
- perf(widget): Optimized `onTimerTriggered` in `widget.qml` to prevent
  redundant daily re-calculations, heavily reducing idle CPU usage.

Medium & Low Priority Fixes:
- fix(PanchangaCalculator): Aligned daily Panchanga transits (Tithis, Nakshatras,
  Yogas, Karanas) strictly to a sunrise-to-sunrise window. Elements ending
  before the morning sunrise are correctly excluded.
- refactor: Centralized duplicated calendar and physics math constants
  (`KaliEpoch`, `DESHANTARA`, `SOLAR_YEAR_IN_DAYS`, `solarMonthsList`)
  into `src/constants.h/cpp`.
- perf(main): Reordered `QCommandLineParser` to execute before loading
  `QQmlApplicationEngine`, allowing instantaneous `--help` and `--version` responses.
- fix(memory): Implemented a size bounds limit (max 200 entries) on
  `calculationCache` in `PanchangaCalculator` to prevent unbounded memory growth.
- test: Added strict data integrity validation at startup for `BsMonthData::NP_MONTHS_DATA`
  and replaced `std::cout` prints in `test_bs.cpp` with strict `assert()` statements.
- fix(qml): Explicitly enforced radix-10 on all `parseInt()` calls across QML
  files to prevent edge-case octal conversions.
- fix(build): Updated `update_version.sh` to use `git describe --tags --always`
  so it doesn't crash in tag-less environments.
@khumnath
khumnath merged commit 437aab1 into main Jun 23, 2026
1 check passed
khumnath added a commit that referenced this pull request Jun 23, 2026
* WIP: Settings UI redesign (tabbed, color picker, sliders)

* Feature: upgrade engine to high-performance C++ backend

- Engine Upgrade: Completely removed the slow JavaScript logic (PanchangaCalculator.js, EventData.js, PreCalculated_Data.js) and migrated all astronomical calculations, events, and data to a native C++ backend for massively improved performance.
- Architecture: Extracted Bikram Sambat date calculations from the monolithic PanchangaCalculator into a dedicated BikramCalendar class (Facade pattern).
- Renaming: Renamed bsmonthdata for better semantic accuracy.
- Testing: Integrated CTest into CMake with JSON baseline verification and --generate flag.
- Developer Experience: Automated compile_commands.json generation for IDE support.
- Documentation: Added Running Tests instructions to READMEs.
- UI/UX & Bug Fixes: Fixed print dialog timing, rounded alpha selector, and bumped version to 2.3.0.
- Cleanup: Fixed misplaced includes and ran code formatting.

* Fix: correct fallback algorithm for early BS dates

- Fixed a boundary error in findAharForBsDate where cross-year date seeking went into unbounded loops or returned incorrect month data.
- Months in early algorithmic years (e.g. BS 998) now calculate precisely without exceeding 32 days.

* Fix: QML date mapping bug for AD years 0-99

- Javascript's Date.UTC() automatically interprets years 0-99 as 1900-1999. This broke the calendar when viewing early BS dates that correspond to the 1st century AD.
- Replaced Date.UTC initialization with setUTCFullYear() which treats 2-digit years exactly literally.

* Fix JS year 0-99 to 1900 mapping bug in QML UI layer

When rendering the calendar by AD year (or converting to JS Date objects), the QML JavaScript engine would silently map AD years 0-99 to 1900-1999 because of Date.UTC() behavior. This caused 'Year 1' to incorrectly show data for 1901 (and map back to BS 1957). Fixed by explicitly calling setUTCFullYear() when year is 0-99.

* UI: fix color picker sliders missing border and unrounded edges

The inner gradients were lacking margins, causing them to draw over the border and mask the rounded corners of the slider tracks.

* Docs: Add copyright notices to source files and address dual-licensing in README

Adds the standard GPLv3 copyright header to all C++ and QML files that were missing it. Also updates the README with a new section clarifying dual licensing for commercial use and referencing the related Web/Android versions.

* Refactor Panchanga calculation logic and update astronomy library formatting

* Core & Calculations:
  - Refactored PanchangaCalculator to use a true sunrise-to-sunrise period when finding daily elements (Tithi, Nakshatra, Yoga, Karana).
  - Updated formatAharTime to accurately wrap times (e.g., 24+ hours) based on the next sunrise instead of a hardcoded 24-hour cycle.
  - Enhanced Bikram Sambat date conversions (bikram.cpp/bikram.h) to fix boundary issues and improve AD <-> BS mappings.

* UI & QML:
  - Updated CalendarLogic.qml to correctly process and display the revised daily events data structures.
  - Adjusted PanchangaDetailDialog.qml to render the new sunrise-relative timings accurately.
  - Minor updates to CalendarGrid.qml and DayCell.qml for improved integration.

* Testing:
  - Rewrote tests/test.cpp to systematically validate QDate transitions across different epochs and century boundaries (e.g., Year 1 AD to 2000 AD).
  - Archived old test files to tests/archive/.

* formatting:
  - Massively reformatted src/astronomy.c to standard block structures for better readability and normalized line endings.
  - Updated build_info.conf and version.conf.

* fix: comprehensive security, memory, and logic audit patches

This commit addresses all critical, high, medium, and low-severity issues
discovered during the deep codebase analysis, improving application
stability, security, and rendering correctness.

Critical & High Priority Fixes:
- fix(TooltipManager): Resolved a severe memory leak by removing the unused
  `showText` method which was dynamically allocating `QQuickView` instances
  without parenting or cleanup.
- fix(helper): Patched a dangling pointer risk by using `QPointer<QQuickWindow>`
  for safe object tracking.
- fix(AutostartManager): Hardened desktop entry creation against path injection
  vulnerabilities by properly quoting Exec paths and sanitizing filenames.
  Fixed uninitialized `m_autostartKey` usage.
- fix(PanchangaCalculator): Prevented out-of-bounds array access in
  `karanaIdx` by clamping the value to `0 - 59`. Fixed `getEventsForDate`
  to use the passed `tz` instead of the hardcoded default `5.75`.
- perf(widget): Optimized `onTimerTriggered` in `widget.qml` to prevent
  redundant daily re-calculations, heavily reducing idle CPU usage.

Medium & Low Priority Fixes:
- fix(PanchangaCalculator): Aligned daily Panchanga transits (Tithis, Nakshatras,
  Yogas, Karanas) strictly to a sunrise-to-sunrise window. Elements ending
  before the morning sunrise are correctly excluded.
- refactor: Centralized duplicated calendar and physics math constants
  (`KaliEpoch`, `DESHANTARA`, `SOLAR_YEAR_IN_DAYS`, `solarMonthsList`)
  into `src/constants.h/cpp`.
- perf(main): Reordered `QCommandLineParser` to execute before loading
  `QQmlApplicationEngine`, allowing instantaneous `--help` and `--version` responses.
- fix(memory): Implemented a size bounds limit (max 200 entries) on
  `calculationCache` in `PanchangaCalculator` to prevent unbounded memory growth.
- test: Added strict data integrity validation at startup for `BsMonthData::NP_MONTHS_DATA`
  and replaced `std::cout` prints in `test_bs.cpp` with strict `assert()` statements.
- fix(qml): Explicitly enforced radix-10 on all `parseInt()` calls across QML
  files to prevent edge-case octal conversions.
- fix(build): Updated `update_version.sh` to use `git describe --tags --always`
  so it doesn't crash in tag-less environments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant