diff options
author | Dave Blake <oak99sky@yahoo.co.uk> | 2020-11-12 16:49:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-12 16:49:34 +0000 |
commit | 186a60b6d210daa5402afad7f8afbc9ef81e04bd (patch) | |
tree | 7a69942cb2a689dfe0690c9dcbbf529c6f2595dc | |
parent | cd65b44056b101e55b95a5bfd5e5699bbe01e737 (diff) | |
parent | e582b8db47c08a8696f7271a3dd05f845dc922a4 (diff) |
Merge pull request #18763 from lrusak/lirc-fix
CLirc: fix segfault by waiting for settings to be loaded
-rw-r--r-- | xbmc/platform/linux/input/LIRC.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/xbmc/platform/linux/input/LIRC.cpp b/xbmc/platform/linux/input/LIRC.cpp index 8dabfefaa4..c04c50cbb4 100644 --- a/xbmc/platform/linux/input/LIRC.cpp +++ b/xbmc/platform/linux/input/LIRC.cpp @@ -12,6 +12,7 @@ #include "ServiceBroker.h" #include "profiles/ProfileManager.h" #include "settings/AdvancedSettings.h" +#include "settings/Settings.h" #include "settings/SettingsComponent.h" #include "utils/log.h" @@ -42,7 +43,18 @@ void CLirc::Start() void CLirc::Process() { - m_profileId = CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetCurrentProfileId(); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + throw std::runtime_error("CSettingsComponent needs to exist before starting CLirc"); + + auto settings = settingsComponent->GetSettings(); + if (!settings) + throw std::runtime_error("CSettings needs to exist before starting CLirc"); + + while (!settings->IsLoaded()) + CThread::Sleep(1000); + + m_profileId = settingsComponent->GetProfileManager()->GetCurrentProfileId(); m_irTranslator.Load("Lircmap.xml"); // make sure work-around (CheckDaemon) uses the same socket path as lirc_init @@ -85,7 +97,7 @@ void CLirc::Process() } if (code != nullptr) { - int profileId = CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetCurrentProfileId(); + int profileId = settingsComponent->GetProfileManager()->GetCurrentProfileId(); if (m_profileId != profileId) { m_profileId = profileId; |