Resolves: tdf#100619 vclptr assert with menu set to menubutton

Change-Id: I2e621567e3bbc01d6f52844014dba9e46fe79f41
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 1b08c29..346a2cf 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -3090,6 +3090,8 @@ bool SvxConfigEntry::IsRenamable()

SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
    : SvxConfigPage(pParent, rSet)
    , m_pMenu(CUI_RES(MODIFY_TOOLBAR))
    , m_pEntry(CUI_RES(MODIFY_TOOLBAR_CONTENT))
{
    SetHelpId( HID_SVX_CONFIG_TOOLBAR );

@@ -3134,19 +3136,17 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
    m_pMoveDownButton->Enable();
    m_pMoveUpButton->Enable();

    VclPtrInstance<PopupMenu> pMenu( CUI_RES( MODIFY_TOOLBAR ) );
    pMenu->SetMenuFlags(
        pMenu->GetMenuFlags() | MenuFlags::AlwaysShowDisabledEntries );
    m_pMenu->SetMenuFlags(
        m_pMenu->GetMenuFlags() | MenuFlags::AlwaysShowDisabledEntries );

    m_pModifyTopLevelButton->SetPopupMenu( pMenu );
    m_pModifyTopLevelButton->SetPopupMenu( m_pMenu );
    m_pModifyTopLevelButton->SetSelectHdl(
        LINK( this, SvxToolbarConfigPage, ToolbarSelectHdl ) );

    VclPtrInstance<PopupMenu> pEntry( CUI_RES( MODIFY_TOOLBAR_CONTENT ) );
    pEntry->SetMenuFlags(
        pEntry->GetMenuFlags() | MenuFlags::AlwaysShowDisabledEntries );
    m_pEntry->SetMenuFlags(
        m_pEntry->GetMenuFlags() | MenuFlags::AlwaysShowDisabledEntries );

    m_pModifyCommandButton->SetPopupMenu( pEntry );
    m_pModifyCommandButton->SetPopupMenu(m_pEntry);
    m_pModifyCommandButton->SetSelectHdl(
        LINK( this, SvxToolbarConfigPage, EntrySelectHdl ) );

@@ -3184,6 +3184,9 @@ void SvxToolbarConfigPage::dispose()
    }
    m_pSaveInListBox->Clear();

    m_pEntry.disposeAndClear();
    m_pMenu.disposeAndClear();

    SvxConfigPage::dispose();
}

diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index 9ca82b4..b9ca0d5 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -575,6 +575,9 @@ private:
    void            DeleteSelectedContent() override;
    void            DeleteSelectedTopLevel() override;

    VclPtrInstance<PopupMenu>                  m_pMenu;
    VclPtrInstance<PopupMenu>                  m_pEntry;

public:
    SvxToolbarConfigPage( vcl::Window *pParent, const SfxItemSet& rItemSet );
    virtual ~SvxToolbarConfigPage();