refactor(api): Change filesAvailable signal to pass list by value #175
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.
Summary
This Pull Request modifies the
IModRepositoryBridge::filesAvailablesignal to pass the list of file info objects by value (QList<ModRepositoryFileInfo>) instead of by a list of raw pointers (QList<ModRepositoryFileInfo*>).This is a prerequisite change required to fix a critical dangling pointer bug in the main ModOrganizer2 application.
Context: The Downstream Bug
In the main application's repository, a critical dangling pointer bug was identified in
NexusBridge::nxmFilesAvailable. This bug could lead to random application crashes. The full context and discussion can be found in the original Pull Request here:ModOrganizer2/modorganizer#2288
During the discussion in that PR, it was determined that the root cause was the unsafe, pointer-based design of the
filesAvailablesignal in thisIModRepositoryBridgeinterface.Design Rationale: Modification vs. Addition
As discussed in the original PR, a key decision was whether to modify the existing signal or add a new, overloaded one for backward compatibility.
This PR modifies the existing signal directly. This is a deliberate breaking change made for the following reasons:
BREAKING CHANGE
The signature of the
IModRepositoryBridge::filesAvailablesignal has been changed fromconst QList<ModRepositoryFileInfo*>&toconst QList<ModRepositoryFileInfo>&.All classes that implement this interface or slots that connect to this signal must be updated to handle a value-based
QList.