[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - cui/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 2 06:35:35 UTC 2019


 cui/source/customize/SvxMenuConfigPage.cxx    |    6 ++++++
 cui/source/customize/SvxToolbarConfigPage.cxx |   17 ++++++++++++++---
 cui/source/customize/cfg.cxx                  |   12 ++++++++----
 3 files changed, 28 insertions(+), 7 deletions(-)

New commits:
commit bd9f2037f379cc3cd887122ca34eedfe85e4e820
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Wed Jan 2 01:24:20 2019 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Wed Jan 2 07:35:13 2019 +0100

    Resolves tdf#122383 and tdf#122410
    
    Add some null pointer checks
    
    Change-Id: I905c6dd46a5019e66d9c2e59374cc7d1ce83397b
    Reviewed-on: https://gerrit.libreoffice.org/65789
    Tested-by: Jenkins
    Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>
    (cherry picked from commit be8897d9c63a77b223a9c0aed1d2eb689e0e0082)
    Reviewed-on: https://gerrit.libreoffice.org/65798

diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 6cf31514352c..bf0247ca5f2c 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -499,6 +499,12 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, ResetMenuHdl, Button *, void )
 {
     SvxConfigEntry* pMenuData = GetTopLevelSelection();
 
+    if (pMenuData == nullptr)
+    {
+        SAL_WARN("cui.customize", "RHB top level selection is null. A menu must be selected to reset!");
+        return;
+    }
+
     std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
                                                    VclMessageType::Question, VclButtonsType::YesNo,
                                                    CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT_MENU)));
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 4ba5682fcd22..84d69f3ef0d0 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -514,9 +514,14 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
 
     // get currently selected toolbar
     SvxConfigEntry* pToolbar = GetTopLevelSelection();
-
     OString sIdent = pButton->GetCurItemIdent();
 
+    if (sIdent.isEmpty() || pToolbar == nullptr)
+    {
+        SAL_WARN("cui.customize", "No toolbar selected, or empty sIdent!");
+        return;
+    }
+
     if (sIdent == "renameItem")
     {
         SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
@@ -855,10 +860,18 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbar, ListBox&, void )
 void SvxToolbarConfigPage::AddFunction(
     SvTreeListEntry* pTarget, bool bFront )
 {
+    SvxConfigEntry* pToolbar = GetTopLevelSelection();
+
+    if (pToolbar == nullptr)
+        return;
+
     // Add the command to the contents listbox of the selected toolbar
     SvTreeListEntry* pNewLBEntry =
         SvxConfigPage::AddFunction( pTarget, bFront, true/*bAllowDuplicates*/ );
 
+    if (pNewLBEntry == nullptr)
+        return;
+
     SvxConfigEntry* pEntry = static_cast<SvxConfigEntry*>(pNewLBEntry->GetUserData());
 
     if ( pEntry->IsBinding() )
@@ -877,8 +890,6 @@ void SvxToolbarConfigPage::AddFunction(
     // TODO: Figure out a way to show the changes on the toolbar, but revert if
     //       the dialog is closed by pressing "Cancel"
     // get currently selected toolbar and apply change
-    SvxConfigEntry* pToolbar = GetTopLevelSelection();
-
     if ( pToolbar != nullptr )
     {
         static_cast<ToolbarSaveInData*>( GetSaveInData() )->ApplyToolbar( pToolbar );
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 55f500612d1a..bfddfef5b6ec 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1599,8 +1599,9 @@ SvTreeListEntry* SvxConfigPage::AddFunction(
     SvTreeListEntry* pTarget, bool bFront, bool bAllowDuplicates )
 {
     OUString aURL = GetScriptURL();
+    SvxConfigEntry* pParent = GetTopLevelSelection();
 
-    if ( aURL.isEmpty() )
+    if ( aURL.isEmpty() || pParent == nullptr )
     {
         return nullptr;
     }
@@ -1623,8 +1624,6 @@ SvTreeListEntry* SvxConfigPage::AddFunction(
         pNewEntryData->SetName( GetSelectedDisplayName() );
 
     // check that this function is not already in the menu
-    SvxConfigEntry* pParent = GetTopLevelSelection();
-
     if ( !bAllowDuplicates )
     {
         for (auto const& entry : *pParent->GetEntries())
@@ -1648,8 +1647,13 @@ SvTreeListEntry* SvxConfigPage::InsertEntry(
     SvTreeListEntry* pTarget,
     bool bFront )
 {
+    SvxConfigEntry* pTopLevelSelection = GetTopLevelSelection();
+
+    if (pTopLevelSelection == nullptr)
+        return nullptr;
+
     // Grab the entries list for the currently selected menu
-    SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
+    SvxEntries* pEntries = pTopLevelSelection->GetEntries();
 
     SvTreeListEntry* pNewEntry = nullptr;
     SvTreeListEntry* pCurEntry =


More information about the Libreoffice-commits mailing list