Skip to content

Update ProjectProcessingPage.cpp - #7214

Open
LezheGao wants to merge 2 commits into
BOINC:masterfrom
LezheGao:master
Open

Update ProjectProcessingPage.cpp#7214
LezheGao wants to merge 2 commits into
BOINC:masterfrom
LezheGao:master

Conversation

@LezheGao

@LezheGao LezheGao commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #6104

Description of the Change
The root cause of was an unsafe cast of a member function pointer in the static event table:

EVT_PROJECTPROCESSING_STATECHANGE( CProjectProcessingPage::OnStateChange )

This macro forced a cast from void (CProjectProcessingPage::*)(CProjectProcessingPageEvent&) to wxEventFunction (i.e., void (wxEvtHandler::*)(wxEvent&)), which is a cast between incompatible pointer types. Under GCC with -Wcast-function-type, this results in undefined behavior – the this pointer is misadjusted when the event handler is called, causing the state machine (m_iCurrentState, flags, and button enable/disable logic) to read/write garbage memory. Consequently, the wizard’s internal page history becomes corrupted, leading to the looping back behaviour and the back button never being greyed out.
To fix this, the static event table entry for wxEVT_PROJECTPROCESSING_STATECHANGE has been removed and replaced with a type‑safe dynamic binding using Bind() in the Create() method. Bind() uses templates to correctly adjust the this pointer, eliminating the UB and the compiler warning. The other static entries (EVT_WIZARDEX_PAGE_CHANGED and EVT_WIZARDEX_CANCEL) are unchanged because they use compatible function signatures.
After this change, the wizard’s state transitions work correctly, the back button follows the expected page history, and it becomes disabled when appropriate.

Assisted-by: (not using an agent): DeepSeek-V4

Alternate Designs
Keeping the static event table but modify the macro to use wxDECLARE_EVENT_TABLE_ENTRY with a proper functor that performs a safe cast. This would require changes in the header file and deeper understanding of wxWidgets’ internal event mechanism, making it more error‑prone and less maintainable.

Release Notes
Fixed erratic "Back" button behaviour in the project attach wizard (Linux builds from master).


Summary by cubic

Fixes #6104 by replacing an unsafe static event handler with a type-safe Bind() for the state-change event. The project attach wizard now advances correctly and disables the Back button when expected.

  • Bug Fixes
    • Replaced static EVT_PROJECTPROCESSING_STATECHANGE entry with Bind(wxEVT_PROJECTPROCESSING_STATECHANGE, &CProjectProcessingPage::OnStateChange, this) in Create().
    • Left EVT_WIZARDEX_PAGE_CHANGED and EVT_WIZARDEX_CANCEL unchanged.

Review in cubic

@LezheGao
LezheGao marked this pull request as draft August 12, 2026 04:15
Deleted redundant annotations
@LezheGao
LezheGao marked this pull request as ready for review August 12, 2026 04:18

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

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.

[Manager] [Linux] When using wizards, clicking on back button causes unexpected pages

1 participant