summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-01-02 01:24:20 +0300
committerAndras Timar <andras.timar@collabora.com>2019-01-17 14:07:37 +0100
commit7216f56cc36eac449e3bb9e2a4ee90ef9540b9cf (patch)
tree02495b277a9296ca51978ea6979d600935c607e3 /cui
parent5d638550eaf9343a56bee9fa0fe8295f37bd3565 (diff)
Resolves tdf#122383 and tdf#122410
Add some null pointer checks Reviewed-on: https://gerrit.libreoffice.org/65789 Tested-by: Jenkins Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com> (cherry picked from commit be8897d9c63a77b223a9c0aed1d2eb689e0e0082) Reviewed-on: https://gerrit.libreoffice.org/65799 (cherry picked from commit 808cc4d5fd87e6e6719a4a16f815e5897608bd2d) Change-Id: I905c6dd46a5019e66d9c2e59374cc7d1ce83397b
Diffstat (limited to 'cui')
-rw-r--r--cui/source/customize/SvxMenuConfigPage.cxx6
-rw-r--r--cui/source/customize/SvxToolbarConfigPage.cxx17
-rw-r--r--cui/source/customize/cfg.cxx12
3 files changed, 28 insertions, 7 deletions
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index aa885a206609..3a5bace9c406 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -450,6 +450,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;
+ }
+
ScopedVclPtrInstance<MessageDialog> qbox(this,
CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT_MENU), VclMessageType::Question, VclButtonsType::YesNo);
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 72e4675b0336..21909025e4fe 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -462,9 +462,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();
@@ -781,10 +786,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() )
@@ -803,8 +816,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 be2f26044a59..7cb1d3623a46 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1626,8 +1626,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;
}
@@ -1650,8 +1651,6 @@ SvTreeListEntry* SvxConfigPage::AddFunction(
pNewEntryData->SetName( GetSelectedDisplayName() );
// check that this function is not already in the menu
- SvxConfigEntry* pParent = GetTopLevelSelection();
-
if ( !bAllowDuplicates )
{
for (SvxEntries::const_iterator iter(pParent->GetEntries()->begin()), end(pParent->GetEntries()->end());
@@ -1678,8 +1677,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 =