fix: Fix screen rotation issues#643
Merged
lzwind merged 2 commits intolinuxdeepin:masterfrom Jun 22, 2025
Merged
Conversation
- Commented out debug logging statements in VNCRecvThread and VNCSendWorker to reduce log clutter. - Enhanced VncViewer with QMutex for thread safety during image updates, size changes, and painting operations. - Added checks for image validity and surface size to prevent crashes during rendering. Log: Fix screen rotation issues.
Reviewer's GuideThis PR addresses screen rotation stability by enforcing thread safety in VncViewer via mutex locking and blocking signal-slot connections, adds validation checks to prevent invalid rendering and sizing operations, and reduces log clutter by commenting out debug statements in send/receive threads. Sequence diagram for image update and screen rotation handling in VncViewersequenceDiagram
participant VNCRecvThread
participant VncViewer
participant QMutex
VNCRecvThread->>VncViewer: updateImage(QImage)
VncViewer->>QMutex: lock (QMutexLocker)
alt image is invalid
VncViewer-->>QMutex: unlock
VncViewer-->>VNCRecvThread: return
else image is valid
alt screen rotation detected
VncViewer->>VncViewer: update m_phoneMode
VncViewer->>VncViewer: setSurfaceSize(new size)
VncViewer->>VncViewer: emit sizeChanged(new size)
end
VncViewer->>VncViewer: m_image = image
VncViewer->>VncViewer: update()
end
VncViewer-->>QMutex: unlock
Class diagram for updated VncViewer thread safety and rendering logicclassDiagram
class VncViewer {
+QMutex m_mutex
+void onSizeChange(int width, int height)
+void clearSurface()
+void updateImage(const QImage &image)
+void paintEvent(QPaintEvent *event)
+void setSurfaceSize(QSize surfaceSize)
+void start()
}
VncViewer --|> QWidget
VncViewer o-- VNCRecvThread : _vncRecvThread
VncViewer o-- VNCSendWorker : _vncSendThread
VncViewer o-- QImage : m_image
VncViewer o-- QPixmap : m_surfacePixmap
VncViewer o-- QPainter : m_painter
VncViewer o-- QTimer : m_frameTimer
VncViewer o-- QMutex : m_mutex
class VNCRecvThread {
+void startRun(rfbClient *cl)
+signal updateImageSignal(QImage)
+signal sizeChangedSignal(int, int)
}
class VNCSendWorker {
+void sendMouseUpdateMsg(rfbClient *cl, int x, int y, int button=0)
+void sendKeyUpdateMsg(rfbClient *cl, int key, bool down)
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @re2zero - I've reviewed your changes - here's some feedback:
- Switching the sizeChangedSignal connection to BlockingQueuedConnection risks deadlocking the UI thread; consider using a non-blocking approach or deferring the resize logic to avoid blocking.
- The heavy use of QMutexLocker across paintEvent, updateImage, and onSizeChange may degrade rendering performance—review lock scope or consider a read/write lock to reduce contention.
- You have duplicated rotation-detection and surface-resizing code in onSizeChange and updateImage—extract that into a shared helper to simplify maintenance.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Switching the sizeChangedSignal connection to BlockingQueuedConnection risks deadlocking the UI thread; consider using a non-blocking approach or deferring the resize logic to avoid blocking.
- The heavy use of QMutexLocker across paintEvent, updateImage, and onSizeChange may degrade rendering performance—review lock scope or consider a read/write lock to reduce contention.
- You have duplicated rotation-detection and surface-resizing code in onSizeChange and updateImage—extract that into a shared helper to simplify maintenance.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Update changelog for version 1.1.7. Log: New v1.1.7 tag.
|
TAG Bot TAG: 1.1.7 |
lzwind
approved these changes
Jun 22, 2025
This was referenced Jun 22, 2025
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.
Log: Fix screen rotation issues.
Summary by Sourcery
Improve VncViewer’s resilience to screen rotation and multithreading by adding mutex protection, image and surface validity checks, and more synchronized thread handling while silencing extraneous debug logs.
Bug Fixes:
Enhancements:
Chores: