diff options
author | Lukas Rusak <lorusak@gmail.com> | 2020-12-05 10:29:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-05 10:29:40 -0800 |
commit | 1d1581dc7f39634c9ea19ad416ab80b869359368 (patch) | |
tree | 1856d681a0110660f2323d61edc5fe4d6e2cc8a5 | |
parent | dc0d193301918eab6600b872bdd771dbe3e8c80c (diff) | |
parent | f0e2ceee305a22039206a9799b131f806f2f7d75 (diff) |
Merge pull request #18837 from lrusak/settings-nullptr
Check settings for nullptr
-rw-r--r-- | xbmc/Application.cpp | 20 | ||||
-rw-r--r-- | xbmc/LangInfo.cpp | 22 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 28 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp | 67 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp | 54 | ||||
-rw-r--r-- | xbmc/network/upnp/UPnPInternal.cpp | 50 | ||||
-rw-r--r-- | xbmc/platform/linux/input/LibInputSettings.cpp | 28 | ||||
-rw-r--r-- | xbmc/powermanagement/PowerManager.cpp | 10 | ||||
-rw-r--r-- | xbmc/settings/Settings.cpp | 25 | ||||
-rw-r--r-- | xbmc/video/dialogs/GUIDialogVideoSettings.cpp | 21 |
10 files changed, 265 insertions, 60 deletions
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 629bfb713f..672fe6ba92 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -796,7 +796,14 @@ bool CApplication::Initialize() CServiceBroker::GetRenderSystem()->ShowSplash(""); m_confirmSkinChange = true; - std::string defaultSkin = std::static_pointer_cast<const CSettingString>(settings->GetSetting(CSettings::SETTING_LOOKANDFEEL_SKIN))->GetDefault(); + auto setting = settings->GetSetting(CSettings::SETTING_LOOKANDFEEL_SKIN); + if (!setting) + { + CLog::Log(LOGFATAL, "Failed to load setting for: {}", CSettings::SETTING_LOOKANDFEEL_SKIN); + return false; + } + + std::string defaultSkin = std::static_pointer_cast<const CSettingString>(setting)->GetDefault(); if (!LoadSkin(settings->GetString(CSettings::SETTING_LOOKANDFEEL_SKIN))) { CLog::Log(LOGERROR, "Failed to load skin '%s'", settings->GetString(CSettings::SETTING_LOOKANDFEEL_SKIN).c_str()); @@ -1164,11 +1171,18 @@ void CApplication::ReloadSkin(bool confirm/*=false*/) else { // skin failed to load - we revert to the default only if we didn't fail loading the default - std::string defaultSkin = std::static_pointer_cast<CSettingString>(settings->GetSetting(CSettings::SETTING_LOOKANDFEEL_SKIN))->GetDefault(); + auto setting = settings->GetSetting(CSettings::SETTING_LOOKANDFEEL_SKIN); + if (!setting) + { + CLog::Log(LOGFATAL, "Failed to load setting for: {}", CSettings::SETTING_LOOKANDFEEL_SKIN); + return; + } + + std::string defaultSkin = std::static_pointer_cast<CSettingString>(setting)->GetDefault(); if (newSkin != defaultSkin) { m_confirmSkinChange = false; - settings->GetSetting(CSettings::SETTING_LOOKANDFEEL_SKIN)->Reset(); + setting->Reset(); CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(24102), g_localizeStrings.Get(24103)); } } diff --git a/xbmc/LangInfo.cpp b/xbmc/LangInfo.cpp index d8b3dc643e..738f7e11ea 100644 --- a/xbmc/LangInfo.cpp +++ b/xbmc/LangInfo.cpp @@ -319,6 +319,14 @@ void CLangInfo::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) if (setting == NULL) return; + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_LOCALE_AUDIOLANGUAGE) SetAudioLanguage(std::static_pointer_cast<const CSettingString>(setting)->GetValue()); @@ -327,7 +335,16 @@ void CLangInfo::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) else if (settingId == CSettings::SETTING_LOCALE_LANGUAGE) { if (!SetLanguage(std::static_pointer_cast<const CSettingString>(setting)->GetValue())) - std::static_pointer_cast<CSettingString>(CServiceBroker::GetSettingsComponent()->GetSettings()->GetSetting(CSettings::SETTING_LOCALE_LANGUAGE))->Reset(); + { + auto setting = settings->GetSetting(CSettings::SETTING_LOCALE_LANGUAGE); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", CSettings::SETTING_LOCALE_LANGUAGE); + return; + } + + std::static_pointer_cast<CSettingString>(setting)->Reset(); + } } else if (settingId == CSettings::SETTING_LOCALE_COUNTRY) SetCurrentRegion(std::static_pointer_cast<const CSettingString>(setting)->GetValue()); @@ -342,7 +359,8 @@ void CLangInfo::OnSettingChanged(const std::shared_ptr<const CSetting>& setting) Set24HourClock(std::static_pointer_cast<const CSettingString>(setting)->GetValue()); // update the time format - CServiceBroker::GetSettingsComponent()->GetSettings()->SetString(CSettings::SETTING_LOCALE_TIMEFORMAT, PrepareTimeFormat(GetTimeFormat(), m_use24HourClock)); + settings->SetString(CSettings::SETTING_LOCALE_TIMEFORMAT, + PrepareTimeFormat(GetTimeFormat(), m_use24HourClock)); } else if (settingId == CSettings::SETTING_LOCALE_TEMPERATUREUNIT) SetTemperatureUnit(std::static_pointer_cast<const CSettingString>(setting)->GetValue()); diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp index 3937e25aed..8024c20816 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp @@ -96,10 +96,32 @@ CDVDVideoCodec* CDVDVideoCodecDRMPRIME::Create(CProcessInfo& processInfo) void CDVDVideoCodecDRMPRIME::Register() { - auto settings = CServiceBroker::GetSettingsComponent()->GetSettings(); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + + auto setting = settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEPRIMEDECODER); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", + CSettings::SETTING_VIDEOPLAYER_USEPRIMEDECODER); + return; + } + + setting->SetVisible(true); + + setting = settings->GetSetting(SETTING_VIDEOPLAYER_USEPRIMEDECODERFORHW); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", SETTING_VIDEOPLAYER_USEPRIMEDECODERFORHW); + return; + } - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEPRIMEDECODER)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEPRIMEDECODERFORHW)->SetVisible(true); + setting->SetVisible(true); CDVDFactoryCodec::RegisterHWVideoCodec("drm_prime", CDVDVideoCodecDRMPRIME::Create); } diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp index 3ad67df4e2..6d254e3063 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp @@ -51,14 +51,14 @@ extern "C" { using namespace VAAPI; #define NUM_RENDER_PICS 7 -const std::string SETTING_VIDEOPLAYER_USEVAAPI = "videoplayer.usevaapi"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIHEVC = "videoplayer.usevaapihevc"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIMPEG2 = "videoplayer.usevaapimpeg2"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIMPEG4 = "videoplayer.usevaapimpeg4"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIVC1 = "videoplayer.usevaapivc1"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIVP8 = "videoplayer.usevaapivp8"; -const std::string SETTING_VIDEOPLAYER_USEVAAPIVP9 = "videoplayer.usevaapivp9"; -const std::string SETTING_VIDEOPLAYER_PREFERVAAPIRENDER = "videoplayer.prefervaapirender"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPI = "videoplayer.usevaapi"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIHEVC = "videoplayer.usevaapihevc"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIMPEG2 = "videoplayer.usevaapimpeg2"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIMPEG4 = "videoplayer.usevaapimpeg4"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIVC1 = "videoplayer.usevaapivc1"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIVP8 = "videoplayer.usevaapivp8"; +constexpr auto SETTING_VIDEOPLAYER_USEVAAPIVP9 = "videoplayer.usevaapivp9"; +constexpr auto SETTING_VIDEOPLAYER_PREFERVAAPIRENDER = "videoplayer.prefervaapirender"; void VAAPI::VaErrorCallback(void *user_context, const char *message) { @@ -543,8 +543,22 @@ bool CDecoder::Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum A auto entry = settings_map.find(avctx->codec_id); if (entry != settings_map.end()) { - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - bool enabled = settings->GetBool(entry->second) && settings->GetSetting(entry->second)->IsVisible(); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return false; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return false; + + auto setting = settings->GetSetting(entry->second); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", entry->second); + return false; + } + + bool enabled = setting->IsEnabled() && setting->IsVisible(); if (!enabled) return false; } @@ -1229,14 +1243,31 @@ void CDecoder::Register(IVaapiWinSystem *winSystem, bool deepColor) CDVDFactoryCodec::RegisterHWAccel("vaapi", CDecoder::Create); config.context->Release(nullptr); - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPI)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIMPEG4)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIVC1)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIMPEG2)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIVP8)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIVP9)->SetVisible(true); - settings->GetSetting(SETTING_VIDEOPLAYER_USEVAAPIHEVC)->SetVisible(true); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + + constexpr std::array<const char*, 8> vaapiSettings = { + SETTING_VIDEOPLAYER_USEVAAPI, SETTING_VIDEOPLAYER_USEVAAPIMPEG4, + SETTING_VIDEOPLAYER_USEVAAPIVC1, SETTING_VIDEOPLAYER_USEVAAPIMPEG2, + SETTING_VIDEOPLAYER_USEVAAPIVP8, SETTING_VIDEOPLAYER_USEVAAPIVP9, + SETTING_VIDEOPLAYER_USEVAAPIHEVC, SETTING_VIDEOPLAYER_PREFERVAAPIRENDER}; + + for (const auto vaapiSetting : vaapiSettings) + { + auto setting = settings->GetSetting(vaapiSetting); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", vaapiSetting); + continue; + } + + setting->SetVisible(true); + } } //----------------------------------------------------------------------------- diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp index 66a6358491..53a3da2f61 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp @@ -516,11 +516,26 @@ bool CDecoder::Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum A { AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1 }, { AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2 }, }; + + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return false; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return false; + auto entry = settings_map.find(avctx->codec_id); if (entry != settings_map.end()) { - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - bool enabled = settings->GetBool(entry->second) && settings->GetSetting(entry->second)->IsVisible(); + auto setting = settings->GetSetting(entry->second); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", entry->second); + return false; + } + + bool enabled = setting->IsEnabled() && setting->IsVisible(); if (!enabled) return false; } @@ -1327,17 +1342,38 @@ void CDecoder::Register() std::transform(gpuvendor.begin(), gpuvendor.end(), gpuvendor.begin(), ::tolower); bool isNvidia = (gpuvendor.compare(0, 6, "nvidia") == 0); - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAU)->SetVisible(true); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + + auto setting = settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAU); + if (!setting) + CLog::Log(LOGERROR, "Failed to load setting for: {}", CSettings::SETTING_VIDEOPLAYER_USEVDPAU); + else + setting->SetVisible(true); if (!isNvidia) { - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4)->SetVisible(true); - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1)->SetVisible(true); - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2)->SetVisible(true); - settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAUMIXER)->SetVisible(true); - } + constexpr std::array<const char*, 4> vdpauSettings = { + CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1, + CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMIXER}; + + for (const auto& vdpauSetting : vdpauSettings) + { + setting = settings->GetSetting(vdpauSetting); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", vdpauSetting); + continue; + } + setting->SetVisible(true); + } + } } //----------------------------------------------------------------------------- diff --git a/xbmc/network/upnp/UPnPInternal.cpp b/xbmc/network/upnp/UPnPInternal.cpp index 652ff364b1..c232e972f2 100644 --- a/xbmc/network/upnp/UPnPInternal.cpp +++ b/xbmc/network/upnp/UPnPInternal.cpp @@ -363,6 +363,14 @@ BuildObject(CFileItem& item, logger->debug("Building didl for object '{}'", item.GetPath()); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return nullptr; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return nullptr; + EClientQuirks quirks = GetClientQuirks(context); // get list of ip addresses @@ -513,7 +521,11 @@ BuildObject(CFileItem& item, break; case VIDEODATABASEDIRECTORY::NODE_TYPE_ACTOR: container->m_ObjectClass.type += ".person.videoArtist"; - container->m_Creator = StringUtils::Join(tag.m_artist, CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_videoItemSeparator).c_str(); + container->m_Creator = + StringUtils::Join( + tag.m_artist, + settingsComponent->GetAdvancedSettings()->m_videoItemSeparator) + .c_str(); container->m_Title = tag.m_strTitle.c_str(); break; case VIDEODATABASEDIRECTORY::NODE_TYPE_SEASONS: @@ -619,8 +631,8 @@ BuildObject(CFileItem& item, // we are being called by a UPnP player or renderer or the user has chosen // to look for external subtitles if (upnp_server != NULL && item.IsVideo() && - (upnp_service == UPnPPlayer || upnp_service == UPnPRenderer || - CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_SERVICES_UPNPLOOKFOREXTERNALSUBTITLES))) + (upnp_service == UPnPPlayer || upnp_service == UPnPRenderer || + settings->GetBool(CSettings::SETTING_SERVICES_UPNPLOOKFOREXTERNALSUBTITLES))) { // find any available external subtitles std::vector<std::string> filenames; @@ -649,20 +661,28 @@ BuildObject(CFileItem& item, } else if (!subtitles.empty()) { - /* trying to find subtitle with prefered language settings */ - std::string preferredLanguage = (CServiceBroker::GetSettingsComponent()->GetSettings()->GetSetting("locale.subtitlelanguage"))->ToString(); - std::string preferredLanguageCode; - g_LangCodeExpander.ConvertToISO6392B(preferredLanguage, preferredLanguageCode); + std::string preferredLanguage{"en"}; - for (unsigned int i = 0; i < subtitles.size(); i++) - { - ExternalStreamInfo info = CUtil::GetExternalStreamDetailsFromFilename(file_path.GetChars(), subtitles[i]); + /* trying to find subtitle with prefered language settings */ + auto setting = settings->GetSetting("locale.subtitlelanguage"); + if (!setting) + CLog::Log(LOGERROR, "Failed to load setting for: {}", "locale.subtitlelanguage"); + else + preferredLanguage = setting->ToString(); + + std::string preferredLanguageCode; + g_LangCodeExpander.ConvertToISO6392B(preferredLanguage, preferredLanguageCode); - if (preferredLanguageCode == info.language) - { - subtitlePath = subtitles[i]; - break; - } + for (unsigned int i = 0; i < subtitles.size(); i++) + { + ExternalStreamInfo info = + CUtil::GetExternalStreamDetailsFromFilename(file_path.GetChars(), subtitles[i]); + + if (preferredLanguageCode == info.language) + { + subtitlePath = subtitles[i]; + break; + } } /* if not found subtitle with prefered language, get the first one */ if (subtitlePath.empty()) diff --git a/xbmc/platform/linux/input/LibInputSettings.cpp b/xbmc/platform/linux/input/LibInputSettings.cpp index 76facff5f9..071c384bd9 100644 --- a/xbmc/platform/linux/input/LibInputSettings.cpp +++ b/xbmc/platform/linux/input/LibInputSettings.cpp @@ -34,12 +34,32 @@ namespace CLibInputSettings::CLibInputSettings(CLibInputHandler *handler) : m_libInputHandler(handler) { + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + + auto settingsManager = settings->GetSettingsManager(); + if (!settingsComponent) + return; + + auto setting = settings->GetSetting(SETTING_INPUT_LIBINPUTKEYBOARDLAYOUT); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", SETTING_INPUT_LIBINPUTKEYBOARDLAYOUT); + return; + } + + setting->SetVisible(true); + std::set<std::string> settingSet; settingSet.insert(SETTING_INPUT_LIBINPUTKEYBOARDLAYOUT); - const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - settings->GetSettingsManager()->RegisterCallback(this, settingSet); - settings->GetSettingsManager()->RegisterSettingOptionsFiller("libinputkeyboardlayout", SettingOptionsKeyboardLayoutsFiller); - settings->GetSetting(SETTING_INPUT_LIBINPUTKEYBOARDLAYOUT)->SetVisible(true); + settingsManager->RegisterCallback(this, settingSet); + settingsManager->RegisterSettingOptionsFiller("libinputkeyboardlayout", + SettingOptionsKeyboardLayoutsFiller); /* load the keyboard layouts from xkeyboard-config */ std::string xkbFile("/usr/share/X11/xkb/rules/base.xml"); diff --git a/xbmc/powermanagement/PowerManager.cpp b/xbmc/powermanagement/PowerManager.cpp index a2714feabb..491d4f3443 100644 --- a/xbmc/powermanagement/PowerManager.cpp +++ b/xbmc/powermanagement/PowerManager.cpp @@ -52,6 +52,14 @@ void CPowerManager::Initialize() void CPowerManager::SetDefaults() { + auto setting = m_settings->GetSetting(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", + CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); + return; + } + int defaultShutdown = m_settings->GetInt(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); switch (defaultShutdown) @@ -91,7 +99,7 @@ void CPowerManager::SetDefaults() break; } - std::static_pointer_cast<CSettingInt>(m_settings->GetSetting(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE))->SetDefault(defaultShutdown); + std::static_pointer_cast<CSettingInt>(setting)->SetDefault(defaultShutdown); } bool CPowerManager::Powerdown() diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp index d4bd941376..2b487339d6 100644 --- a/xbmc/settings/Settings.cpp +++ b/xbmc/settings/Settings.cpp @@ -725,18 +725,37 @@ void CSettings::InitializeDefaults() // when we do this (eg non-Aero on ATI in particular) and on others (AppleTV) we can't get XBMC to // the front if (g_sysinfo.IsAeroDisabled()) - std::static_pointer_cast<CSettingBool>(GetSettingsManager()->GetSetting(CSettings::SETTING_VIDEOSCREEN_FAKEFULLSCREEN))->SetDefault(false); + { + auto setting = GetSettingsManager()->GetSetting(CSettings::SETTING_VIDEOSCREEN_FAKEFULLSCREEN); + if (!setting) + CLog::Log(LOGERROR, "Failed to load setting for: {}", + CSettings::SETTING_VIDEOSCREEN_FAKEFULLSCREEN); + else + std::static_pointer_cast<CSettingBool>(setting)->SetDefault(false); + } #endif if (g_application.IsStandAlone()) - std::static_pointer_cast<CSettingInt>(GetSettingsManager()->GetSetting(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE))->SetDefault(POWERSTATE_SHUTDOWN); + { + auto setting = + GetSettingsManager()->GetSetting(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); + if (!setting) + CLog::Log(LOGERROR, "Failed to load setting for: {}", + CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); + else + std::static_pointer_cast<CSettingInt>(setting)->SetDefault(POWERSTATE_SHUTDOWN); + } // Initialize deviceUUID if not already set, used in zeroconf advertisements. std::shared_ptr<CSettingString> deviceUUID = std::static_pointer_cast<CSettingString>(GetSettingsManager()->GetSetting(CSettings::SETTING_SERVICES_DEVICEUUID)); if (deviceUUID->GetValue().empty()) { const std::string& uuid = StringUtils::CreateUUID(); - std::static_pointer_cast<CSettingString>(GetSettingsManager()->GetSetting(CSettings::SETTING_SERVICES_DEVICEUUID))->SetValue(uuid); + auto setting = GetSettingsManager()->GetSetting(CSettings::SETTING_SERVICES_DEVICEUUID); + if (!setting) + CLog::Log(LOGERROR, "Failed to load setting for: {}", CSettings::SETTING_SERVICES_DEVICEUUID); + else + std::static_pointer_cast<CSettingString>(setting)->SetValue(uuid); } } diff --git a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp index e3f99a54d4..2a47300c56 100644 --- a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp @@ -213,10 +213,27 @@ void CGUIDialogVideoSettings::OnSettingAction(const std::shared_ptr<const CSetti { const std::shared_ptr<CProfileManager> profileManager = CServiceBroker::GetSettingsComponent()->GetProfileManager(); + auto settingsComponent = CServiceBroker::GetSettingsComponent(); + if (!settingsComponent) + return; + + auto settings = settingsComponent->GetSettings(); + if (!settings) + return; + + auto setting = settings->GetSetting(CSettings::SETTING_VIDEOSCREEN_GUICALIBRATION); + if (!setting) + { + CLog::Log(LOGERROR, "Failed to load setting for: {}", + CSettings::SETTING_VIDEOSCREEN_GUICALIBRATION); + return; + } + // launch calibration window - if (profileManager->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && - g_passwordManager.CheckSettingLevelLock(CServiceBroker::GetSettingsComponent()->GetSettings()->GetSetting(CSettings::SETTING_VIDEOSCREEN_GUICALIBRATION)->GetLevel())) + if (profileManager->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && + g_passwordManager.CheckSettingLevelLock(setting->GetLevel())) return; + CServiceBroker::GetGUI()->GetWindowManager().ForceActivateWindow(WINDOW_SCREEN_CALIBRATION); } //! @todo implement |