Update ProjectProcessingPage.cpp - #7214
Open
LezheGao wants to merge 2 commits into
Open
Conversation
LezheGao
marked this pull request as draft
August 12, 2026 04:15
Deleted redundant annotations
LezheGao
marked this pull request as ready for review
August 12, 2026 04:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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&)towxEventFunction(i.e.,void (wxEvtHandler::*)(wxEvent&)), which is a cast between incompatible pointer types. Under GCC with-Wcast-function-type, this results in undefined behavior – thethispointer 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_STATECHANGEhas been removed and replaced with a type‑safe dynamic binding usingBind()in theCreate()method.Bind()uses templates to correctly adjust thethispointer, eliminating the UB and the compiler warning. The other static entries (EVT_WIZARDEX_PAGE_CHANGEDandEVT_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_ENTRYwith 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.EVT_PROJECTPROCESSING_STATECHANGEentry withBind(wxEVT_PROJECTPROCESSING_STATECHANGE, &CProjectProcessingPage::OnStateChange, this)inCreate().EVT_WIZARDEX_PAGE_CHANGEDandEVT_WIZARDEX_CANCELunchanged.