More lifecycle correction.

   Another (complete) audit of delete usage in:
        "vclwidget: change all vcl::window fields to be wrapped in VclPtr"

Change-Id: I828212ded66ecc5cc30c75a4de626c7b386cb77a
diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx
index baf1acf..e6c680e 100644
--- a/avmedia/source/framework/mediacontrol.cxx
+++ b/avmedia/source/framework/mediacontrol.cxx
@@ -202,7 +202,7 @@ MediaControl::~MediaControl()
void MediaControl::dispose()
{
    maZoomToolBox->SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, NULL );
    mpZoomListBox.clear();
    mpZoomListBox.disposeAndClear();
    maTimeEdit.disposeAndClear();
    maZoomToolBox.disposeAndClear();
    maVolumeSlider.disposeAndClear();
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index e7784af..076aa3e 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -2875,7 +2875,7 @@ CodeCompleteWindow::~CodeCompleteWindow()

void CodeCompleteWindow::dispose()
{
    pListBox.clear();
    pListBox.disposeAndClear();
    pParent.clear();
    vcl::Window::dispose();
}
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 248c765..89a79b7 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1568,14 +1568,14 @@ void SvxConfigPage::dispose()
    m_pContents.clear();
    m_pContentsLabel.clear();
    m_pEntries.clear();
    m_pContentsListBox.clear();
    m_pContentsListBox.disposeAndClear();
    m_pAddCommandsButton.clear();
    m_pModifyCommandButton.clear();
    m_pMoveUpButton.clear();
    m_pMoveDownButton.clear();
    m_pSaveInListBox.clear();
    m_pDescriptionField.clear();
    m_pSelectorDlg.clear();
    m_pSelectorDlg.disposeAndClear();
    SfxTabPage::dispose();
}

@@ -2979,8 +2979,8 @@ void SvxToolbarConfigPage::dispose()
    }
    m_pSaveInListBox->Clear();

    m_pSelectorDlg.clear();
    m_pContentsListBox.clear();
    m_pSelectorDlg.disposeAndClear();
    m_pContentsListBox.disposeAndClear();
    SvxConfigPage::dispose();
}

diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index 0d8b428..b74c37e 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -508,7 +508,7 @@ void OfaSwAutoFmtOptionsPage::dispose()
        delete pCheckButtonData;
        pCheckButtonData = NULL;
    }
    m_pCheckLB.clear();
    m_pCheckLB.disposeAndClear();
    m_pEditPB.clear();
    SfxTabPage::dispose();
}
@@ -1892,8 +1892,8 @@ void OfaQuoteTabPage::dispose()
{
    delete pCheckButtonData;
    pCheckButtonData = NULL;
    m_pSwCheckLB.clear();
    m_pCheckLB.clear();
    m_pSwCheckLB.disposeAndClear();
    m_pCheckLB.disposeAndClear();
    m_pSingleTypoCB.clear();
    m_pSglStartQuotePB.clear();
    m_pSglStartExFT.clear();
diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx
index cf9bc11..5f9643b 100644
--- a/dbaccess/source/ui/misc/WTypeSelect.cxx
+++ b/dbaccess/source/ui/misc/WTypeSelect.cxx
@@ -265,7 +265,7 @@ OWizTypeSelect::~OWizTypeSelect()

void OWizTypeSelect::dispose()
{
    m_pTypeControl.clear();
    m_pTypeControl.disposeAndClear();
    m_pColumnNames.clear();
    m_pColumns.clear();
    m_pAutoType.clear();
diff --git a/formula/source/ui/dlg/funcutl.cxx b/formula/source/ui/dlg/funcutl.cxx
index c6747f9..716dc88 100644
--- a/formula/source/ui/dlg/funcutl.cxx
+++ b/formula/source/ui/dlg/funcutl.cxx
@@ -380,7 +380,7 @@ EditBox::~EditBox()
void EditBox::dispose()
{
    pMEdit->Disable();
    pMEdit.clear();
    pMEdit.disposeAndClear();
    Control::dispose();
}

diff --git a/sd/source/ui/annotations/annotationwindow.cxx b/sd/source/ui/annotations/annotationwindow.cxx
index 7ca80ef..48ed13a 100644
--- a/sd/source/ui/annotations/annotationwindow.cxx
+++ b/sd/source/ui/annotations/annotationwindow.cxx
@@ -296,11 +296,11 @@ AnnotationWindow::~AnnotationWindow()

void AnnotationWindow::dispose()
{
    mpMeta.clear();
    mpMeta.disposeAndClear();
    delete mpOutlinerView;
    delete mpOutliner;
    mpVScrollbar.clear();
    mpTextWindow.clear();
    mpVScrollbar.disposeAndClear();
    mpTextWindow.disposeAndClear();
    FloatingWindow::dispose();
}

diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index e65a8a5..2c6d161 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -3080,10 +3080,9 @@ SfxHelpWindow_Impl::~SfxHelpWindow_Impl()
void SfxHelpWindow_Impl::dispose()
{
    SaveConfig();
    pIndexWin.clear();

    pIndexWin.disposeAndClear();
    pTextWin->CloseFrame();
    pTextWin.clear();
    pTextWin.disposeAndClear();
    SplitWindow::dispose();
}

diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 9b18e99..0122bbd 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -2142,11 +2142,11 @@ CustomPropertiesControl::~CustomPropertiesControl()

void CustomPropertiesControl::dispose()
{
    m_pVertScroll.clear();
    m_pPropertiesWin.clear();
    m_pBody.clear();
    m_pHeaderBar.clear();
    m_pVBox.clear();
    m_pVertScroll.disposeAndClear();
    m_pPropertiesWin.disposeAndClear();
    m_pBody.disposeAndClear();
    m_pHeaderBar.disposeAndClear();
    m_pVBox.disposeAndClear();
    vcl::Window::dispose();
}

diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index 5739784..9dcccbc 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -80,40 +80,23 @@ Deck::~Deck()

void Deck::dispose()
{
    Dispose();
    SharedPanelContainer aPanels;
    aPanels.swap(maPanels);

    // We have to explicitly trigger the destruction of panels.
    // Otherwise that is done by one of our base class destructors
    // without updating maPanels.
    for (size_t i = 0; i < maPanels.size(); i++)
        maPanels[i]->dispose();

    for (size_t i = 0; i < aPanels.size(); i++)
        aPanels[i].disposeAndClear();
    maPanels.clear();
    vcl::Window::dispose();
}

void Deck::Dispose (void)
{
    SharedPanelContainer aPanels;
    aPanels.swap(maPanels);
    for (SharedPanelContainer::iterator
             iPanel(aPanels.begin()),
             iEnd(aPanels.end());
         iPanel!=iEnd;
         ++iPanel)
    {
        if (*iPanel)
        {
            (*iPanel)->Dispose();
            iPanel->disposeAndClear();
        }
    }

    mpTitleBar.disposeAndClear();
    mpFiller.disposeAndClear();
    mpVerticalScrollBar.disposeAndClear();
    mpScrollContainer.disposeAndClear();
    mpScrollClipWindow.disposeAndClear();

    vcl::Window::dispose();
}

DeckTitleBar* Deck::GetTitleBar (void) const
diff --git a/sfx2/source/sidebar/Deck.hxx b/sfx2/source/sidebar/Deck.hxx
index 6aaeabe..d4416ab 100644
--- a/sfx2/source/sidebar/Deck.hxx
+++ b/sfx2/source/sidebar/Deck.hxx
@@ -49,8 +49,6 @@ public:
    virtual ~Deck (void);
    virtual void dispose() SAL_OVERRIDE;

    void Dispose (void);

    const ::rtl::OUString& GetId (void) const { return msId;}
    DeckTitleBar* GetTitleBar (void) const;
    Rectangle GetContentArea (void) const;
diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx
index 2f33b95..8be4f28 100644
--- a/sfx2/source/sidebar/Panel.cxx
+++ b/sfx2/source/sidebar/Panel.cxx
@@ -76,12 +76,6 @@ Panel::~Panel()

void Panel::dispose()
{
    Dispose();
    vcl::Window::dispose();
}

void Panel::Dispose (void)
{
    mxPanelComponent = NULL;

    {
@@ -98,6 +92,8 @@ void Panel::Dispose (void)
    }

    mpTitleBar.disposeAndClear();

    vcl::Window::dispose();
}

PanelTitleBar* Panel::GetTitleBar (void) const
diff --git a/sfx2/source/sidebar/Panel.hxx b/sfx2/source/sidebar/Panel.hxx
index edacf7e..f72c880 100644
--- a/sfx2/source/sidebar/Panel.hxx
+++ b/sfx2/source/sidebar/Panel.hxx
@@ -49,8 +49,6 @@ public:
    virtual ~Panel (void);
    virtual void dispose() SAL_OVERRIDE;

    void Dispose (void);

    PanelTitleBar* GetTitleBar (void) const;
    bool IsTitleBarOptional (void) const { return mbIsTitleBarOptional;}
    void SetUIElement (const css::uno::Reference<css::ui::XUIElement>& rxElement);
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index dd66551..ee99a28 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -203,9 +203,8 @@ void SAL_CALL SidebarController::disposing (void)

    if (mpCurrentDeck)
    {
        mpCurrentDeck->Dispose();
        mpCurrentDeck->PrintWindowTree();
        mpCurrentDeck.disposeAndClear();
//        mpCurrentDeck->PrintWindowTree();
    }

    mpTabBar.disposeAndClear();
@@ -535,11 +534,7 @@ void SidebarController::SwitchToDeck (
    {
        // When the deck changes then destroy the deck and all panels
        // and create everything new.
        if (mpCurrentDeck)
        {
            mpCurrentDeck->Dispose();
            mpCurrentDeck.disposeAndClear();
        }
        mpCurrentDeck.disposeAndClear();

        msCurrentDeckId = rDeckDescriptor.msId;
    }
diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
index ed4522f3..5f9d022 100644
--- a/svx/source/dialog/docrecovery.cxx
+++ b/svx/source/dialog/docrecovery.cxx
@@ -932,7 +932,7 @@ RecoveryDialog::~RecoveryDialog()

void RecoveryDialog::dispose()
{
    m_pFileListLB.clear();
    m_pFileListLB.disposeAndClear();
    m_pTitleFT.clear();
    m_pDescrFT.clear();
    m_pProgrParent.clear();
diff --git a/svx/source/form/tabwin.cxx b/svx/source/form/tabwin.cxx
index 0887b43..e795a49 100644
--- a/svx/source/form/tabwin.cxx
+++ b/svx/source/form/tabwin.cxx
@@ -209,7 +209,7 @@ void FmFieldWin::dispose()
        m_pChangeListener->release();
        //  delete m_pChangeListener;
    }
    pListBox.clear();
    pListBox.disposeAndClear();
    delete pData;
    SfxFloatingWindow::dispose();
}
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx
index 8aea398..0d0fe95 100644
--- a/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx
@@ -561,8 +561,8 @@ ChineseDictionaryDialog::~ChineseDictionaryDialog()
void ChineseDictionaryDialog::dispose()
{
    m_xContext=0;
    m_pCT_DictionaryToSimplified.clear();
    m_pCT_DictionaryToTraditional.clear();
    m_pCT_DictionaryToSimplified.disposeAndClear();
    m_pCT_DictionaryToTraditional.disposeAndClear();
    m_pRB_To_Simplified.clear();
    m_pRB_To_Traditional.clear();
    m_pCB_Reverse.clear();
diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx b/sw/source/ui/dbui/mmoutputtypepage.cxx
index 09cf2cf..a99333e 100644
--- a/sw/source/ui/dbui/mmoutputtypepage.cxx
+++ b/sw/source/ui/dbui/mmoutputtypepage.cxx
@@ -334,7 +334,7 @@ void SwSendMailDialog::dispose()
        }
    }
    delete m_pImpl;
    m_pStatus.clear();
    m_pStatus.disposeAndClear();
    m_pTransferStatus.clear();
    m_pPaused.clear();
    m_pProgressBar.clear();
diff --git a/vcl/source/window/btndlg.cxx b/vcl/source/window/btndlg.cxx
index b0552ff..3acbad5 100644
--- a/vcl/source/window/btndlg.cxx
+++ b/vcl/source/window/btndlg.cxx
@@ -334,7 +334,10 @@ void ButtonDialog::RemoveButton( sal_uInt16 nId )
        if (it->mnId == nId)
        {
            it->mpPushButton->Hide();
            it->mpPushButton.clear();
            if (it->mbOwnButton)
                it->mpPushButton.disposeAndClear();
            else
                it->mpPushButton.clear();
            maItemList.erase(it);
            return;
        }
@@ -348,7 +351,8 @@ void ButtonDialog::Clear()
    for (btn_iterator it = maItemList.begin(); it != maItemList.end(); ++it)
    {
        it->mpPushButton->Hide();
        it->mpPushButton.disposeAndClear();
        if (it->mbOwnButton)
            it->mpPushButton.disposeAndClear();
    }

    maItemList.clear();
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 3bc1a63..309a8b7 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -2036,7 +2036,6 @@ void MessageDialog::dispose()

    m_pPrimaryMessage.disposeAndClear();
    m_pSecondaryMessage.disposeAndClear();
    m_pSecondaryMessage.disposeAndClear();
    m_pImage.disposeAndClear();
    m_pGrid.disposeAndClear();
    m_pOwnedActionArea.disposeAndClear();