Kaydet (Commit) be8897d9 authored tarafından Muhammet Kara's avatar Muhammet Kara

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: 's avatarMuhammet Kara <muhammet.kara@collabora.com>
üst 9c9558bf
...@@ -499,6 +499,12 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, ResetMenuHdl, Button *, void ) ...@@ -499,6 +499,12 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, ResetMenuHdl, Button *, void )
{ {
SvxConfigEntry* pMenuData = GetTopLevelSelection(); 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(), std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
VclMessageType::Question, VclButtonsType::YesNo, VclMessageType::Question, VclButtonsType::YesNo,
CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT_MENU))); CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT_MENU)));
......
...@@ -514,9 +514,14 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void ) ...@@ -514,9 +514,14 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
// get currently selected toolbar // get currently selected toolbar
SvxConfigEntry* pToolbar = GetTopLevelSelection(); SvxConfigEntry* pToolbar = GetTopLevelSelection();
OString sIdent = pButton->GetCurItemIdent(); OString sIdent = pButton->GetCurItemIdent();
if (sIdent.isEmpty() || pToolbar == nullptr)
{
SAL_WARN("cui.customize", "No toolbar selected, or empty sIdent!");
return;
}
if (sIdent == "renameItem") if (sIdent == "renameItem")
{ {
SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry(); SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
...@@ -855,10 +860,18 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbar, ListBox&, void ) ...@@ -855,10 +860,18 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbar, ListBox&, void )
void SvxToolbarConfigPage::AddFunction( void SvxToolbarConfigPage::AddFunction(
SvTreeListEntry* pTarget, bool bFront ) SvTreeListEntry* pTarget, bool bFront )
{ {
SvxConfigEntry* pToolbar = GetTopLevelSelection();
if (pToolbar == nullptr)
return;
// Add the command to the contents listbox of the selected toolbar // Add the command to the contents listbox of the selected toolbar
SvTreeListEntry* pNewLBEntry = SvTreeListEntry* pNewLBEntry =
SvxConfigPage::AddFunction( pTarget, bFront, true/*bAllowDuplicates*/ ); SvxConfigPage::AddFunction( pTarget, bFront, true/*bAllowDuplicates*/ );
if (pNewLBEntry == nullptr)
return;
SvxConfigEntry* pEntry = static_cast<SvxConfigEntry*>(pNewLBEntry->GetUserData()); SvxConfigEntry* pEntry = static_cast<SvxConfigEntry*>(pNewLBEntry->GetUserData());
if ( pEntry->IsBinding() ) if ( pEntry->IsBinding() )
...@@ -877,8 +890,6 @@ void SvxToolbarConfigPage::AddFunction( ...@@ -877,8 +890,6 @@ void SvxToolbarConfigPage::AddFunction(
// TODO: Figure out a way to show the changes on the toolbar, but revert if // TODO: Figure out a way to show the changes on the toolbar, but revert if
// the dialog is closed by pressing "Cancel" // the dialog is closed by pressing "Cancel"
// get currently selected toolbar and apply change // get currently selected toolbar and apply change
SvxConfigEntry* pToolbar = GetTopLevelSelection();
if ( pToolbar != nullptr ) if ( pToolbar != nullptr )
{ {
static_cast<ToolbarSaveInData*>( GetSaveInData() )->ApplyToolbar( pToolbar ); static_cast<ToolbarSaveInData*>( GetSaveInData() )->ApplyToolbar( pToolbar );
......
...@@ -1600,8 +1600,9 @@ SvTreeListEntry* SvxConfigPage::AddFunction( ...@@ -1600,8 +1600,9 @@ SvTreeListEntry* SvxConfigPage::AddFunction(
SvTreeListEntry* pTarget, bool bFront, bool bAllowDuplicates ) SvTreeListEntry* pTarget, bool bFront, bool bAllowDuplicates )
{ {
OUString aURL = GetScriptURL(); OUString aURL = GetScriptURL();
SvxConfigEntry* pParent = GetTopLevelSelection();
if ( aURL.isEmpty() ) if ( aURL.isEmpty() || pParent == nullptr )
{ {
return nullptr; return nullptr;
} }
...@@ -1624,8 +1625,6 @@ SvTreeListEntry* SvxConfigPage::AddFunction( ...@@ -1624,8 +1625,6 @@ SvTreeListEntry* SvxConfigPage::AddFunction(
pNewEntryData->SetName( GetSelectedDisplayName() ); pNewEntryData->SetName( GetSelectedDisplayName() );
// check that this function is not already in the menu // check that this function is not already in the menu
SvxConfigEntry* pParent = GetTopLevelSelection();
if ( !bAllowDuplicates ) if ( !bAllowDuplicates )
{ {
for (auto const& entry : *pParent->GetEntries()) for (auto const& entry : *pParent->GetEntries())
...@@ -1649,8 +1648,13 @@ SvTreeListEntry* SvxConfigPage::InsertEntry( ...@@ -1649,8 +1648,13 @@ SvTreeListEntry* SvxConfigPage::InsertEntry(
SvTreeListEntry* pTarget, SvTreeListEntry* pTarget,
bool bFront ) bool bFront )
{ {
SvxConfigEntry* pTopLevelSelection = GetTopLevelSelection();
if (pTopLevelSelection == nullptr)
return nullptr;
// Grab the entries list for the currently selected menu // Grab the entries list for the currently selected menu
SvxEntries* pEntries = GetTopLevelSelection()->GetEntries(); SvxEntries* pEntries = pTopLevelSelection->GetEntries();
SvTreeListEntry* pNewEntry = nullptr; SvTreeListEntry* pNewEntry = nullptr;
SvTreeListEntry* pCurEntry = SvTreeListEntry* pCurEntry =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment