fix: use QQuickOpenGLUtils to reset OpenGL state#773
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:
|
TAG Bot New tag: 0.8.6 |
|
TAG Bot New tag: 0.8.7 |
Summary by Sourcery
Bug Fixes: