fix: use QQuickOpenGLUtils to reset OpenGL state#773
Open
zzxyb wants to merge 1 commit intolinuxdeepin:masterfrom
Open
fix: use QQuickOpenGLUtils to reset OpenGL state#773zzxyb wants to merge 1 commit intolinuxdeepin:masterfrom
zzxyb wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zzxyb The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors the OpenGL state reset logic for QSGRendererInterface::OpenGL outputs to use Qt’s QQuickOpenGLUtils helper instead of manually unbinding buffers and disabling depth testing, relying on Qt’s centralized state restoration. Sequence diagram for OpenGL state reset using QQuickOpenGLUtilssequenceDiagram
participant WOutputRenderWindow
participant resetGlState
participant WRenderHelper
participant QSGRendererInterface
participant QQuickOpenGLUtils
WOutputRenderWindow->>resetGlState: invoke()
resetGlState->>WRenderHelper: getGraphicsApi()
WRenderHelper-->>resetGlState: graphicsApi
alt graphicsApi is OpenGL
resetGlState->>QSGRendererInterface: OpenGL (enum value)
resetGlState->>QQuickOpenGLUtils: resetOpenGLState()
QQuickOpenGLUtils-->>resetGlState: OpenGL state reset
else graphicsApi is not OpenGL
resetGlState-->>WOutputRenderWindow: no operation
end
resetGlState-->>WOutputRenderWindow: return
Class diagram for OpenGL state reset refactorclassDiagram
class WOutputRenderWindow {
}
class WRenderHelper {
+static QSGRendererInterface::GraphicsApi getGraphicsApi()
}
class QSGRendererInterface {
<<enum>>
OpenGL
Software
Vulkan
Metal
Direct3D11
}
class QQuickOpenGLUtils {
+static void resetOpenGLState()
}
class GlobalFunctions {
+static void resetGlState()
}
GlobalFunctions ..> WRenderHelper : uses
GlobalFunctions ..> QSGRendererInterface : checksGraphicsApi
GlobalFunctions ..> QQuickOpenGLUtils : calls
WOutputRenderWindow ..> GlobalFunctions : calls resetGlState()
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Consider guarding the
node->markDirty(QSGNode::DirtyNodeRemoved);call with a null check to avoid dereferencing a null pointer whenupdatePaintNodeis invoked withnode == nullptr.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider guarding the `node->markDirty(QSGNode::DirtyNodeRemoved);` call with a null check to avoid dereferencing a null pointer when `updatePaintNode` is invoked with `node == nullptr`.
## Individual Comments
### Comment 1
<location path="waylib/src/server/qtquick/wquickcursor.cpp" line_range="578" />
<code_context>
// Ignore the tp->proxy, Don't use tp->qwBuffer()
if (!tp->buffer) {
- delete node;
+ node->markDirty(QSGNode::DirtyNodeRemoved);
return nullptr;
}
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against null `node` and clarify ownership/lifetime when replacing `delete` with `markDirty`.
`delete node;` was safe for null and freed the node. The new `node->markDirty(...)` will crash if `node` is null (e.g. on first call), and `markDirty(QSGNode::DirtyNodeRemoved)` does not itself destroy the node. Please guard the call, e.g. `if (node) node->markDirty(QSGNode::DirtyNodeRemoved);`, and verify that the scene graph will delete a root node that is only marked removed but returned as `nullptr`, or otherwise restore explicit deletion to avoid a leak.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
0e259e2 to
1e954ef
Compare
Replace manual OpenGL state reset with QQuickOpenGLUtils::resetOpenGLState() to properly restore the Qt Quick rendering state. Log: Influence:
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.
Summary by Sourcery
Bug Fixes: