CommonHostInterface: Prevent some potential null pointer dereferences

This commit is contained in:
Albert Liu 2020-07-21 17:14:11 -07:00
parent c8b6712010
commit 855fc9a31c
2 changed files with 8 additions and 2 deletions

View File

@ -484,6 +484,9 @@ void QtHostInterface::connectDisplaySignals(QtDisplayWidget* widget)
void QtHostInterface::updateDisplayState() void QtHostInterface::updateDisplayState()
{ {
if (!m_display)
return;
// this expects the context to get moved back to us afterwards // this expects the context to get moved back to us afterwards
m_display->DoneRenderContextCurrent(); m_display->DoneRenderContextCurrent();

View File

@ -551,13 +551,16 @@ bool CommonHostInterface::ResumeSystemFromMostRecentState()
void CommonHostInterface::UpdateSpeedLimiterState() void CommonHostInterface::UpdateSpeedLimiterState()
{ {
if (!m_system || !m_audio_stream || !m_display)
return;
m_speed_limiter_enabled = m_settings.speed_limiter_enabled && !m_speed_limiter_temp_disabled; m_speed_limiter_enabled = m_settings.speed_limiter_enabled && !m_speed_limiter_temp_disabled;
const bool is_non_standard_speed = (std::abs(m_settings.emulation_speed - 1.0f) > 0.05f); const bool is_non_standard_speed = (std::abs(m_settings.emulation_speed - 1.0f) > 0.05f);
const bool audio_sync_enabled = const bool audio_sync_enabled =
!m_system || m_paused || (m_speed_limiter_enabled && m_settings.audio_sync_enabled && !is_non_standard_speed); m_paused || (m_speed_limiter_enabled && m_settings.audio_sync_enabled && !is_non_standard_speed);
const bool video_sync_enabled = const bool video_sync_enabled =
!m_system || m_paused || (m_speed_limiter_enabled && m_settings.video_sync_enabled && !is_non_standard_speed); m_paused || (m_speed_limiter_enabled && m_settings.video_sync_enabled && !is_non_standard_speed);
Log_InfoPrintf("Syncing to %s%s", audio_sync_enabled ? "audio" : "", Log_InfoPrintf("Syncing to %s%s", audio_sync_enabled ? "audio" : "",
(audio_sync_enabled && video_sync_enabled) ? " and video" : (video_sync_enabled ? "video" : "")); (audio_sync_enabled && video_sync_enabled) ? " and video" : (video_sync_enabled ? "video" : ""));