Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
5.15.16
-
None
Description
My program crashes at QWindowsScreenManager::removeScreen
Finally execute
QWindowSystemInterface::handleScreenRemoved(m_screens.takeAt(index));
Index is accessed out of bounds here. Reproduction steps:
1. The screen moves to the following layout
Screen 1: (1920*1080 100%)
Screen 3: (1920*1080 100%)
Screen 2: (2560*1440 150%) Main screen
2. Run the demo program
3. Removing screen 3 will trigger a crash at QWindowSystemInterface::handleScreenRemoved(m_screens.takeAt(index));
It is recommended to determine whether index is still within the range of m_screens before executing QWindowSystemInterface::handleScreenRemoved(m_screens.takeAt(index)); to protect against this situation.
I debugged the Qt source code and found that there were two calls to QWindowsScreenManager::removeScreen. The first removeScreen was executed with index 2 and screens size 3. Before the first removeScreen was completed, the second removeScreen was executed (same index 2 and screens size 3). Then the second removeScreen deleted the element with index 2. Then when the first removeScreen was executed, an out-of-bounds access occurred.
Is there something wrong with what I'm using here or is there something wrong with Qt? Do you have any more suggestions? Thank you very much~