mirror of
https://github.com/jellyfin/jellyfin-media-player.git
synced 2025-02-18 21:08:17 +00:00
Fix potential crash in restorePreviousVideoMode()
We did get a crash upload about it. And indeed, the display and/or mode list can asynchronously change, making these IDs invalid. Verify them before doing anything. The "correct" fix would probably be getting rid of these IDs, but this will have to wait for later. Also, the DisplayManager::isValid* methods erroneously accepted negative IDs as valid, which is definitely wrong. (No, the QMap.size method does not return an unsigned integer either.)
This commit is contained in:
parent
6b105231ab
commit
b2e23d7c53
@ -193,7 +193,7 @@ bool DisplayComponent::restorePreviousVideoMode()
|
||||
if (!m_displayManager)
|
||||
return false;
|
||||
|
||||
if (m_lastVideoMode < 0 || m_lastDisplay < 0)
|
||||
if (!m_displayManager->isValidDisplayMode(m_lastDisplay, m_lastVideoMode))
|
||||
return false;
|
||||
|
||||
bool ret = true;
|
||||
|
@ -61,13 +61,13 @@ DMVideoModePtr DisplayManager::getCurrentVideoMode(int display)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool DisplayManager::isValidDisplay(int display) { return display < displays.size(); }
|
||||
bool DisplayManager::isValidDisplay(int display) { return display >= 0 && display < displays.size(); }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool DisplayManager::isValidDisplayMode(int display, int mode)
|
||||
{
|
||||
if (display < displays.size())
|
||||
if (displays[display]->videoModes.size() > mode)
|
||||
if (isValidDisplay(display))
|
||||
if (mode >= 0 && mode < displays[display]->videoModes.size())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user