[Windows] Fix crash when Kodi is moved to another monitor with different video adapter #19782
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.
Description
Fix crash when Kodi is moved to another monitor with different video adapter due to hardware changed.
Fixes #15295 (if is not already fixed by #19768)
Motivation and context
This is very similar to #19768. This time are different monitors and different video adapters.
How has this been tested?
System with internal video adapter Intel 630 and Nvidia adapter and is configured with two monitors (Intel primary and desktop extended to monitor 2 (Nvidia). Kodi is running on monitor 2 (Nvidia).
Changed Windows display settings to one monitor (Intel) while Kodi is running on Nvidia. Kodi switches at monitor 1 and when is restored full screen crashes.
The root cause is that method
CWinSystemWin32DX::OnMove(int x, int y)
is called two times:Call 1
current_monitor = Nvidia
new_monitor = Intel
m_monitor = new_monitor; ---> at this time Kodi knows that is at Intel monitor. All right.
Call 2 (because Kodi interprets NULL monitor as new monitor again)
current_monitor = Intel
new_monitor = NULL
m_monitor = NULL; --> crash
Without fix crash by access to null pointer.
With fix is discarded this second call.
What is the effect on users?
Fix crash when Kodi switches from monitor due hardware config changed and new monitor is on another video adapter.
Types of change
Checklist: