From 0ae863c8ac4b712d67041e8bcf4069afbe71b494 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 13 Sep 2016 08:13:16 +0200 Subject: tdf#101976 cui: fix crash when setting AutoCheckEnabled and it is read-only With instdir/share/registry/data/registrymodifications.xcu being: false and then trying to set 'Check for updates automatically' in Tools -> Options -> LibreOffice -> Online Update. Change-Id: Ifb196b6351c8a9182dfcf2ddf0a1e0555bcccedd Reviewed-on: https://gerrit.libreoffice.org/28856 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- cui/source/options/optupdt.cxx | 13 ++++++++++--- cui/source/options/optupdt.hxx | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx index 3623bd65200c..ae2aec7acb1d 100644 --- a/cui/source/options/optupdt.cxx +++ b/cui/source/options/optupdt.cxx @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -67,6 +69,7 @@ SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxIt uno::Reference < uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); m_xUpdateAccess = setup::UpdateCheckConfig::create( xContext ); + m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(xContext, "*"); bool bDownloadSupported = false; m_xUpdateAccess->getByName( "DownloadSupported" ) >>= bDownloadSupported; @@ -274,11 +277,15 @@ void SvxOnlineUpdateTabPage::Reset( const SfxItemSet* ) { bool bValue = false; m_xUpdateAccess->getByName( "AutoCheckEnabled" ) >>= bValue; + OUStringLiteral sPath("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/AutoCheckEnabled"); + beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(sPath); + bool bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; m_pAutoCheckCheckBox->Check(bValue); - m_pEveryDayButton->Enable(bValue); - m_pEveryWeekButton->Enable(bValue); - m_pEveryMonthButton->Enable(bValue); + m_pAutoCheckCheckBox->Enable(!bReadOnly); + m_pEveryDayButton->Enable(bValue && !bReadOnly); + m_pEveryWeekButton->Enable(bValue && !bReadOnly); + m_pEveryMonthButton->Enable(bValue && !bReadOnly); sal_Int64 nValue = 0; m_xUpdateAccess->getByName( "CheckInterval" ) >>= nValue; diff --git a/cui/source/options/optupdt.hxx b/cui/source/options/optupdt.hxx index 9460930fc164..04a97b742f74 100644 --- a/cui/source/options/optupdt.hxx +++ b/cui/source/options/optupdt.hxx @@ -23,6 +23,7 @@ #include #include #include +#include // class SvxPathTabPage -------------------------------------------------- @@ -50,6 +51,7 @@ private: DECL_LINK_TYPED(ExtrasCheckHdl_Impl, Button*, void); css::uno::Reference< css::container::XNameReplace > m_xUpdateAccess; + css::uno::Reference m_xReadWriteAccess; void UpdateLastCheckedText(); void UpdateUserAgent(); -- cgit