[Libreoffice-commits] core.git: Branch 'feature/vclptr' - 20 commits - avmedia/source basctl/source chart2/source connectivity/source cui/source dbaccess/source fpicker/source include/dbaccess include/vcl reportdesign/source sc/source sfx2/source starmath/qa starmath/source svtools/source svx/source sw/source vcl/inc vcl/qa vcl/source

Michael Meeks michael.meeks at collabora.com
Thu Apr 9 14:29:25 PDT 2015


 avmedia/source/framework/mediacontrol.cxx                    |    1 
 avmedia/source/viewer/mediawindow_impl.cxx                   |    3 
 basctl/source/basicide/baside2b.cxx                          |    8 +
 basctl/source/basicide/baside3.cxx                           |    1 
 basctl/source/basicide/bastype2.cxx                          |    3 
 basctl/source/basicide/macrodlg.cxx                          |    3 
 basctl/source/basicide/moduldl2.cxx                          |   16 ++-
 basctl/source/basicide/moduldlg.cxx                          |    9 +
 basctl/source/basicide/objdlg.cxx                            |    3 
 chart2/source/controller/dialogs/dlg_ChartType.cxx           |    1 
 chart2/source/controller/dialogs/dlg_DataSource.cxx          |   11 +-
 chart2/source/controller/dialogs/dlg_ObjectProperties.cxx    |    2 
 chart2/source/controller/dialogs/dlg_View3D.cxx              |    3 
 chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx |    1 
 chart2/source/controller/dialogs/tp_AxisLabel.cxx            |    1 
 chart2/source/controller/dialogs/tp_ChartType.cxx            |    6 +
 chart2/source/controller/dialogs/tp_PointGeometry.cxx        |    1 
 chart2/source/controller/dialogs/tp_TitleRotation.cxx        |    1 
 chart2/source/controller/main/ChartWindow.cxx                |    1 
 connectivity/source/drivers/file/fcomp.cxx                   |    2 
 cui/source/customize/acccfg.cxx                              |    2 
 cui/source/customize/cfg.cxx                                 |   35 ++++---
 cui/source/dialogs/SpellDialog.cxx                           |   16 +--
 cui/source/dialogs/colorpicker.cxx                           |    2 
 cui/source/dialogs/cuifmsearch.cxx                           |    9 -
 cui/source/dialogs/cuigaldlg.cxx                             |    4 
 cui/source/dialogs/cuihyperdlg.cxx                           |    2 
 cui/source/dialogs/dlgname.cxx                               |    1 
 cui/source/dialogs/hangulhanjadlg.cxx                        |   16 +--
 cui/source/dialogs/hldocntp.cxx                              |    8 -
 cui/source/dialogs/hltpbase.cxx                              |    2 
 cui/source/dialogs/iconcdlg.cxx                              |   18 ++-
 cui/source/dialogs/insdlg.cxx                                |    3 
 cui/source/dialogs/multipat.cxx                              |   13 +-
 cui/source/dialogs/srchxtra.cxx                              |    1 
 cui/source/options/certpath.cxx                              |    1 
 cui/source/options/dbregister.cxx                            |    1 
 cui/source/options/fontsubs.cxx                              |    3 
 cui/source/options/optaccessibility.cxx                      |    1 
 cui/source/options/optasian.cxx                              |    1 
 cui/source/options/optchart.cxx                              |   13 +-
 cui/source/options/optcolor.cxx                              |   45 ++++++---
 cui/source/options/optfltr.cxx                               |    2 
 cui/source/options/optgdlg.cxx                               |    4 
 cui/source/options/optinet2.cxx                              |    5 -
 cui/source/options/optjava.cxx                               |   16 ++-
 cui/source/options/optlingu.cxx                              |    6 -
 cui/source/options/optpath.cxx                               |   13 +-
 cui/source/options/optsave.cxx                               |    3 
 cui/source/options/treeopt.cxx                               |    6 -
 cui/source/options/webconninfo.cxx                           |    2 
 cui/source/tabpages/align.cxx                                |    1 
 cui/source/tabpages/autocdlg.cxx                             |   19 ++-
 cui/source/tabpages/backgrnd.cxx                             |   14 ++
 cui/source/tabpages/chardlg.cxx                              |    3 
 cui/source/tabpages/numfmt.cxx                               |    2 
 cui/source/tabpages/numpages.cxx                             |   19 +++
 cui/source/tabpages/page.cxx                                 |    2 
 cui/source/tabpages/tpbitmap.cxx                             |    3 
 cui/source/tabpages/tpcolor.cxx                              |    3 
 cui/source/tabpages/tpline.cxx                               |   13 +-
 dbaccess/source/core/dataaccess/databasedocument.cxx         |    1 
 dbaccess/source/ui/app/AppDetailPageHelper.cxx               |    8 +
 dbaccess/source/ui/app/AppDetailPageHelper.hxx               |    4 
 dbaccess/source/ui/app/AppView.cxx                           |   15 ++-
 dbaccess/source/ui/browser/dataview.cxx                      |   14 +-
 fpicker/source/office/PlacesListBox.cxx                      |    3 
 include/dbaccess/dataview.hxx                                |    4 
 include/vcl/builder.hxx                                      |   11 ++
 include/vcl/tabpage.hxx                                      |    2 
 include/vcl/vclptr.hxx                                       |   27 +++++
 include/vcl/window.hxx                                       |    3 
 reportdesign/source/ui/dlg/Condition.cxx                     |    1 
 reportdesign/source/ui/report/DesignView.cxx                 |    2 
 sc/source/ui/app/inputwin.cxx                                |    6 +
 sfx2/source/appl/newhelp.cxx                                 |    3 
 sfx2/source/dialog/backingwindow.cxx                         |    1 
 sfx2/source/dialog/basedlgs.cxx                              |    5 -
 sfx2/source/dialog/dockwin.cxx                               |    4 
 sfx2/source/sidebar/Deck.cxx                                 |    5 +
 sfx2/source/sidebar/SidebarToolBox.cxx                       |    2 
 sfx2/source/sidebar/TabBar.cxx                               |    2 
 starmath/qa/cppunit/test_starmath.cxx                        |    8 -
 starmath/source/edit.cxx                                     |   13 ++
 starmath/source/toolbox.cxx                                  |    5 +
 svtools/source/brwbox/brwbox1.cxx                            |    1 
 svtools/source/contnr/imivctl1.cxx                           |    1 
 svtools/source/contnr/ivctrl.cxx                             |   17 ++-
 svtools/source/contnr/treelistbox.cxx                        |   52 ++++++----
 svtools/source/control/ctrlbox.cxx                           |   16 ++-
 svtools/source/control/headbar.cxx                           |   13 +-
 svtools/source/control/ruler.cxx                             |    5 +
 svx/source/dialog/ctredlin.cxx                               |    4 
 svx/source/dialog/docrecovery.cxx                            |    1 
 svx/source/dialog/svxruler.cxx                               |   11 +-
 svx/source/fmcomp/fmgridcl.cxx                               |    3 
 svx/source/fmcomp/gridctrl.cxx                               |    7 +
 svx/source/form/datanavi.cxx                                 |    6 +
 svx/source/sidebar/PanelLayout.cxx                           |    1 
 svx/source/tbxctrls/tbcontrl.cxx                             |   15 +--
 sw/source/core/view/viewsh.cxx                               |    2 
 sw/source/ui/index/cnttab.cxx                                |    2 
 sw/source/uibase/docvw/FrameControlsManager.cxx              |    5 +
 sw/source/uibase/docvw/PageBreakWin.cxx                      |    6 +
 sw/source/uibase/docvw/SidebarWin.cxx                        |    4 
 sw/source/uibase/docvw/edtwin.cxx                            |   15 ++-
 sw/source/uibase/inc/FrameControlsManager.hxx                |    3 
 sw/source/uibase/sidebar/PagePropertyPanel.cxx               |    8 +
 vcl/inc/svdata.hxx                                           |    2 
 vcl/inc/window.h                                             |    5 -
 vcl/qa/cppunit/lifecycle.cxx                                 |   32 +++++-
 vcl/source/app/svapp.cxx                                     |    7 +
 vcl/source/app/svmain.cxx                                    |    6 -
 vcl/source/control/button.cxx                                |    9 -
 vcl/source/control/combobox.cxx                              |    6 -
 vcl/source/control/ctrl.cxx                                  |    8 +
 vcl/source/control/lstbox.cxx                                |    4 
 vcl/source/control/scrbar.cxx                                |    2 
 vcl/source/control/tabctrl.cxx                               |    4 
 vcl/source/window/accessibility.cxx                          |    2 
 vcl/source/window/builder.cxx                                |   13 ++
 vcl/source/window/dialog.cxx                                 |   14 ++
 vcl/source/window/dockwin.cxx                                |    3 
 vcl/source/window/event.cxx                                  |    6 +
 vcl/source/window/floatwin.cxx                               |    4 
 vcl/source/window/mouse.cxx                                  |    6 -
 vcl/source/window/settings.cxx                               |    8 -
 vcl/source/window/split.cxx                                  |    8 +
 vcl/source/window/splitwin.cxx                               |    3 
 vcl/source/window/stacking.cxx                               |    2 
 vcl/source/window/syswin.cxx                                 |   27 +++--
 vcl/source/window/tabpage.cxx                                |   11 ++
 vcl/source/window/toolbox.cxx                                |    7 +
 vcl/source/window/window.cxx                                 |   51 +++++++---
 vcl/source/window/window2.cxx                                |   55 ++++++-----
 135 files changed, 754 insertions(+), 308 deletions(-)

New commits:
commit 954e5e4b7820c5db3a6720dc9dc27e49cee449ac
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Mar 2 22:02:19 2015 +0000

    prophylactic double dispose audit.
    
    Change-Id: Ia18c0b7a76fb0894efe33afaf69a0079c4583228

diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx
index e222a64..617bbc3 100644
--- a/avmedia/source/framework/mediacontrol.cxx
+++ b/avmedia/source/framework/mediacontrol.cxx
@@ -203,6 +203,7 @@ void MediaControl::dispose()
 {
     maZoomToolBox->SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, NULL );
     delete mpZoomListBox;
+    mpZoomListBox = NULL;
     maTimeEdit.disposeAndClear();
     maZoomToolBox.disposeAndClear();
     maVolumeSlider.disposeAndClear();
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx
index 2042858..b2716ee 100644
--- a/avmedia/source/viewer/mediawindow_impl.cxx
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -201,8 +201,11 @@ void MediaWindowImpl::dispose()
     mpMediaWindow = NULL;
 
     delete mpEmptyBmpEx;
+    mpEmptyBmpEx = NULL;
     delete mpAudioBmpEx;
+    mpAudioBmpEx = NULL;
     delete mpMediaWindowControl;
+    mpMediaWindowControl = NULL;
     Control::dispose();
 }
 
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index be6895c..4afce39 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -1683,7 +1683,8 @@ void WatchWindow::dispose()
     aRemoveWatchButton.disposeAndClear();
     aHeaderBar.disposeAndClear();
     aTreeListBox.disposeAndClear();
-    GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
+    if (!IsDisposed())
+        GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
     DockingWindow::dispose();
 }
 
@@ -1928,7 +1929,8 @@ StackWindow::~StackWindow()
 
 void StackWindow::dispose()
 {
-    GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
+    if (!IsDisposed())
+        GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
     aTreeListBox.disposeAndClear();
     DockingWindow::dispose();
 }
@@ -2177,6 +2179,7 @@ void WatchTreeListBox::dispose()
     while ( pEntry )
     {
         delete static_cast<WatchItem*>(pEntry->GetUserData());
+        pEntry->SetUserData(NULL);
         pEntry = Next( pEntry );
     }
     SvHeaderTabListBox::dispose();
@@ -2861,6 +2864,7 @@ CodeCompleteWindow::~CodeCompleteWindow()
 void CodeCompleteWindow::dispose()
 {
     delete pListBox;
+    pListBox = NULL;
     vcl::Window::dispose();
 }
 
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index 642981f..a85d0e0 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -1417,6 +1417,7 @@ void DialogWindowLayout::dispose()
     {
         Remove(pPropertyBrowser);
         delete pPropertyBrowser;
+        pPropertyBrowser = 0;
     }
     Layout::dispose();
 }
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index 8abf230..feb01c0 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -217,7 +217,8 @@ void TreeListBox::dispose()
     SvTreeListEntry* pEntry = First();
     while ( pEntry )
     {
-        delete static_cast<Entry*>(pEntry->GetUserData());
+        delete static_cast<Entry*>( pEntry->GetUserData() );
+        pEntry->SetUserData( NULL );
         pEntry = Next( pEntry );
     }
     SvTreeListBox::dispose();
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 53355ef..31d8bcc 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -118,7 +118,10 @@ MacroChooser::~MacroChooser()
 void MacroChooser::dispose()
 {
     if ( bForceStoreBasic )
+    {
         SfxGetpApp()->SaveBasicAndDialogContainer();
+        bForceStoreBasic = false;
+    }
     SfxModalDialog::dispose();
 }
 
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index 48cd1ed..f7cfbb5 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -167,12 +167,14 @@ CheckBox::~CheckBox()
 void CheckBox::dispose()
 {
     delete pCheckButton;
+    pCheckButton = NULL;
 
     // delete user data
     SvTreeListEntry* pEntry = First();
     while ( pEntry )
     {
-        delete static_cast<LibUserData*>(pEntry->GetUserData());
+        delete static_cast<LibUserData*>( pEntry->GetUserData() );
+        pEntry->SetUserData( NULL );
         pEntry = Next( pEntry );
     }
     SvTabListBox::dispose();
@@ -487,11 +489,15 @@ LibPage::~LibPage()
 
 void LibPage::dispose()
 {
-    sal_uInt16 nCount = m_pBasicsBox->GetEntryCount();
-    for ( sal_uInt16 i = 0; i < nCount; ++i )
+    if (m_pBasicsBox)
     {
-        DocumentEntry* pEntry = static_cast<DocumentEntry*>(m_pBasicsBox->GetEntryData( i ));
-        delete pEntry;
+        sal_uInt16 nCount = m_pBasicsBox->GetEntryCount();
+        for ( sal_uInt16 i = 0; i < nCount; ++i )
+        {
+            DocumentEntry* pEntry = static_cast<DocumentEntry*>(m_pBasicsBox->GetEntryData( i ));
+            delete pEntry;
+        }
+        m_pBasicsBox = NULL;
     }
     TabPage::dispose();
 }
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 9d3185b..216fb1d 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -491,8 +491,13 @@ OrganizeDialog::~OrganizeDialog()
 
 void OrganizeDialog::dispose()
 {
-    for ( sal_uInt16 i = 0; i < m_pTabCtrl->GetPageCount(); i++ )
-        delete m_pTabCtrl->GetTabPage( m_pTabCtrl->GetPageId( i ) );
+    if (m_pTabCtrl)
+    {
+        for ( sal_uInt16 i = 0; i < m_pTabCtrl->GetPageCount(); i++ )
+            delete m_pTabCtrl->GetTabPage( m_pTabCtrl->GetPageId( i ) );
+        m_pTabCtrl = NULL;
+    }
+
     TabDialog::dispose();
 };
 
diff --git a/basctl/source/basicide/objdlg.cxx b/basctl/source/basicide/objdlg.cxx
index 14d943f..8c29c63 100644
--- a/basctl/source/basicide/objdlg.cxx
+++ b/basctl/source/basicide/objdlg.cxx
@@ -74,7 +74,8 @@ ObjectCatalog::~ObjectCatalog()
 
 void ObjectCatalog::dispose()
 {
-    GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow(this);
+    if (!IsDisposed())
+        GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow(this);
     aTitle.disposeAndClear();
     aTree.disposeAndClear();
     DockingWindow::dispose();
diff --git a/chart2/source/controller/dialogs/dlg_ChartType.cxx b/chart2/source/controller/dialogs/dlg_ChartType.cxx
index 9ef9432d..33cf747 100644
--- a/chart2/source/controller/dialogs/dlg_ChartType.cxx
+++ b/chart2/source/controller/dialogs/dlg_ChartType.cxx
@@ -61,6 +61,7 @@ ChartTypeDialog::~ChartTypeDialog()
 void ChartTypeDialog::dispose()
 {
     delete m_pChartTypeTabPage;
+    m_pChartTypeTabPage = NULL;
     ModalDialog::dispose();
 }
 
diff --git a/chart2/source/controller/dialogs/dlg_DataSource.cxx b/chart2/source/controller/dialogs/dlg_DataSource.cxx
index e59c95e..88c1a41 100644
--- a/chart2/source/controller/dialogs/dlg_DataSource.cxx
+++ b/chart2/source/controller/dialogs/dlg_DataSource.cxx
@@ -165,10 +165,15 @@ DataSourceDialog::~DataSourceDialog()
 void DataSourceDialog::dispose()
 {
     delete m_pRangeChooserTabePage;
+    m_pRangeChooserTabePage = NULL;
     delete m_pDataSourceTabPage;
-
-    m_nLastPageId = m_pTabControl->GetCurPageId();
-    delete m_pTabControl;
+    m_pDataSourceTabPage = NULL;
+    if (m_pTabControl)
+    {
+        m_nLastPageId = m_pTabControl->GetCurPageId();
+        delete m_pTabControl;
+        m_pTabControl = NULL;
+    }
     TabDialog::dispose();
 }
 
diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
index 25b87fc..0a563e2 100644
--- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
+++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
@@ -487,7 +487,9 @@ SchAttribTabDlg::~SchAttribTabDlg()
 void SchAttribTabDlg::dispose()
 {
     delete m_pSymbolShapeProperties;
+    m_pSymbolShapeProperties = NULL;
     delete m_pAutoSymbolGraphic;
+    m_pAutoSymbolGraphic = NULL;
     SfxTabDialog::dispose();
 }
 
diff --git a/chart2/source/controller/dialogs/dlg_View3D.cxx b/chart2/source/controller/dialogs/dlg_View3D.cxx
index 6308f58..3769f2e 100644
--- a/chart2/source/controller/dialogs/dlg_View3D.cxx
+++ b/chart2/source/controller/dialogs/dlg_View3D.cxx
@@ -72,8 +72,11 @@ View3DDialog::~View3DDialog()
 void View3DDialog::dispose()
 {
     delete m_pGeometry;
+    m_pGeometry = NULL;
     delete m_pAppearance;
+    m_pAppearance = NULL;
     delete m_pIllumination;
+    m_pIllumination = NULL;
 
     m_nLastPageId = m_pTabControl->GetCurPageId();
     TabDialog::dispose();
diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx
index defb3343..2c92a75 100644
--- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx
+++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx
@@ -300,6 +300,7 @@ ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage()
 void ThreeD_SceneIllumination_TabPage::dispose()
 {
     delete[] m_pLightSourceInfoList;
+    m_pLightSourceInfoList = NULL;
     TabPage::dispose();
 }
 
diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx
index 85b6570..0cded26 100644
--- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx
+++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx
@@ -78,6 +78,7 @@ SchAxisLabelTabPage::~SchAxisLabelTabPage()
 void SchAxisLabelTabPage::dispose()
 {
     delete m_pOrientHlp;
+    m_pOrientHlp = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx
index 2b41ab2..c717903 100644
--- a/chart2/source/controller/dialogs/tp_ChartType.cxx
+++ b/chart2/source/controller/dialogs/tp_ChartType.cxx
@@ -780,11 +780,17 @@ void ChartTypeTabPage::dispose()
 
     //delete all resource helper
     delete m_pDim3DLookResourceGroup;
+    m_pDim3DLookResourceGroup = NULL;
     delete m_pStackingResourceGroup;
+    m_pStackingResourceGroup = NULL;
     delete m_pSplineResourceGroup;
+    m_pSplineResourceGroup = NULL;
     delete m_pGeometryResourceGroup;
+    m_pGeometryResourceGroup = NULL;
     delete m_pSortByXValuesResourceGroup;
+    m_pSortByXValuesResourceGroup = NULL;
     delete m_pGL3DResourceGroup;
+    m_pGL3DResourceGroup = NULL;
     svt::OWizardPage::dispose();
 }
 
diff --git a/chart2/source/controller/dialogs/tp_PointGeometry.cxx b/chart2/source/controller/dialogs/tp_PointGeometry.cxx
index c65ef3a..dc8e84c 100644
--- a/chart2/source/controller/dialogs/tp_PointGeometry.cxx
+++ b/chart2/source/controller/dialogs/tp_PointGeometry.cxx
@@ -45,6 +45,7 @@ SchLayoutTabPage::~SchLayoutTabPage()
 void SchLayoutTabPage::dispose()
 {
     delete m_pGeometryResources;
+    m_pGeometryResources = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.cxx b/chart2/source/controller/dialogs/tp_TitleRotation.cxx
index 45ee087..a83373d 100644
--- a/chart2/source/controller/dialogs/tp_TitleRotation.cxx
+++ b/chart2/source/controller/dialogs/tp_TitleRotation.cxx
@@ -63,6 +63,7 @@ SchAlignmentTabPage::~SchAlignmentTabPage()
 void SchAlignmentTabPage::dispose()
 {
     delete m_pOrientHlp;
+    m_pOrientHlp = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx
index 8926b94..fafc90a 100644
--- a/connectivity/source/drivers/file/fcomp.cxx
+++ b/connectivity/source/drivers/file/fcomp.cxx
@@ -60,7 +60,7 @@ void OPredicateCompiler::dispose()
 {
     Clean();
     m_orgColumns        = NULL;
-m_xIndexes.clear();
+    m_xIndexes.clear();
 }
 
 void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode)
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index d6a2c53..a65e565 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -828,6 +828,8 @@ void SfxAcceleratorConfigPage::dispose()
     m_pKeyBox->Clear();
 
     delete m_pFileDlg;
+    m_pFileDlg = NULL;
+
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 7c108a6..8fc2b26 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -2233,9 +2233,13 @@ void SvxMenuConfigPage::dispose()
 
         delete pData;
     }
+    m_pSaveInListBox->Clear();
 
     delete m_pSelectorDlg;
+    m_pSelectorDlg = NULL;
     delete m_pContentsListBox;
+    m_pContentsListBox = NULL;
+
     SvxConfigPage::dispose();
 }
 
@@ -2925,14 +2929,14 @@ void SvxToolbarConfigPage::dispose()
 
         delete pData;
     }
+    m_pSaveInListBox->Clear();
 
-    if ( m_pSelectorDlg != NULL )
-    {
-        delete m_pSelectorDlg;
-    }
-
+    delete m_pSelectorDlg;
+    m_pSelectorDlg = NULL;
 
     delete m_pContentsListBox;
+    m_pContentsListBox = NULL;
+
     SvxConfigPage::dispose();
 }
 
@@ -4531,6 +4535,8 @@ SvxToolbarEntriesListBox::~SvxToolbarEntriesListBox()
 void SvxToolbarEntriesListBox::dispose()
 {
     delete m_pButtonData;
+    m_pButtonData = NULL;
+
     SvxMenuEntriesListBox::dispose();
 }
 
@@ -4920,20 +4926,23 @@ SvxIconSelectorDialog::~SvxIconSelectorDialog()
 
 void SvxIconSelectorDialog::dispose()
 {
-    sal_uInt16 nCount = pTbSymbol->GetItemCount();
-
-    for (sal_uInt16 n = 0; n < nCount; ++n )
+    if (pTbSymbol)
     {
-        sal_uInt16 nId = pTbSymbol->GetItemId(n);
-
-        uno::XInterface* xi = static_cast< uno::XInterface* >(
-            pTbSymbol->GetItemData( nId ) );
+        sal_uInt16 nCount = pTbSymbol->GetItemCount();
 
-        if ( xi != NULL )
+        for (sal_uInt16 n = 0; n < nCount; ++n )
         {
+            sal_uInt16 nId = pTbSymbol->GetItemId(n);
+
+            uno::XInterface* xi = static_cast< uno::XInterface* >(
+                pTbSymbol->GetItemData( nId ) );
+
+            if ( xi != NULL )
             xi->release();
         }
+        pTbSymbol = NULL;
     }
+
     ModalDialog::dispose();
 }
 
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index 2d130a5..5c81f1c 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -251,19 +251,19 @@ SpellDialog::~SpellDialog()
 
 void SpellDialog::dispose()
 {
-    // save possibly modified user-dictionaries
-    Reference< XSearchableDictionaryList >  xDicList( SvxGetDictionaryList() );
-    if (xDicList.is())
+    if (pImpl)
     {
-        SaveDictionaries( xDicList );
-    }
+        // save possibly modified user-dictionaries
+        Reference< XSearchableDictionaryList >  xDicList( SvxGetDictionaryList() );
+        if (xDicList.is())
+            SaveDictionaries( xDicList );
 
-    delete pImpl;
+        delete pImpl;
+        pImpl = NULL;
+    }
     SfxModelessDialog::dispose();
 }
 
-
-
 void SpellDialog::Init_Impl()
 {
     // initialize handler
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx
index 76619da..7edff10 100644
--- a/cui/source/dialogs/colorpicker.cxx
+++ b/cui/source/dialogs/colorpicker.cxx
@@ -366,6 +366,7 @@ ColorFieldControl::~ColorFieldControl()
 void ColorFieldControl::dispose()
 {
     delete mpBitmap;
+    mpBitmap = NULL;
     Control::dispose();
 }
 
@@ -758,6 +759,7 @@ ColorSliderControl::~ColorSliderControl()
 void ColorSliderControl::dispose()
 {
     delete mpBitmap;
+    mpBitmap = NULL;
     Control::dispose();
 }
 
diff --git a/cui/source/dialogs/cuifmsearch.cxx b/cui/source/dialogs/cuifmsearch.cxx
index d651f0e..c8bbf0a 100644
--- a/cui/source/dialogs/cuifmsearch.cxx
+++ b/cui/source/dialogs/cuifmsearch.cxx
@@ -170,13 +170,12 @@ void FmSearchDialog::dispose()
 
     SaveParams();
 
-    if (m_pConfig)
-    {
-        delete m_pConfig;
-        m_pConfig = NULL;
-    }
+    delete m_pConfig;
+    m_pConfig = NULL;
 
     delete m_pSearchEngine;
+    m_pSearchEngine = NULL;
+
     ModalDialog::dispose();
 }
 
diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx
index 27337db..ac330ae 100644
--- a/cui/source/dialogs/cuigaldlg.cxx
+++ b/cui/source/dialogs/cuigaldlg.cxx
@@ -767,11 +767,11 @@ void TPGalleryThemeProperties::dispose()
     for ( size_t i = 0, n = aFilterEntryList.size(); i < n; ++i ) {
         delete aFilterEntryList[ i ];
     }
+    aFilterEntryList.clear();
+
     SfxTabPage::dispose();
 }
 
-
-
 SfxTabPage* TPGalleryThemeProperties::Create( vcl::Window* pParent, const SfxItemSet* rSet )
 {
     return new TPGalleryThemeProperties( pParent, *rSet );
diff --git a/cui/source/dialogs/cuihyperdlg.cxx b/cui/source/dialogs/cuihyperdlg.cxx
index bb5463e..99f8dadd 100644
--- a/cui/source/dialogs/cuihyperdlg.cxx
+++ b/cui/source/dialogs/cuihyperdlg.cxx
@@ -167,6 +167,8 @@ void SvxHpLinkDlg::dispose()
     aViewOpt.Delete();
 
     delete mpItemSet;
+    mpItemSet = NULL;
+
     IconChoiceDialog::dispose();
 }
 
diff --git a/cui/source/dialogs/dlgname.cxx b/cui/source/dialogs/dlgname.cxx
index 1f6c663..4a49494 100644
--- a/cui/source/dialogs/dlgname.cxx
+++ b/cui/source/dialogs/dlgname.cxx
@@ -144,6 +144,7 @@ SvxMessDialog::~SvxMessDialog()
 void SvxMessDialog::dispose()
 {
     delete pImage;
+    pImage = NULL;
     ModalDialog::dispose();
 }
 
diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx
index 46136a9..6d8e101 100644
--- a/cui/source/dialogs/hangulhanjadlg.cxx
+++ b/cui/source/dialogs/hangulhanjadlg.cxx
@@ -1139,17 +1139,17 @@ namespace svx
 
     void HangulHanjaOptionsDialog::dispose()
     {
-        SvTreeListEntry*    pEntry = m_pDictsLB->First();
+        SvTreeListEntry* pEntry = m_pDictsLB->First();
         while( pEntry )
         {
-            OUString const * pDel = static_cast<OUString const *>(pEntry->GetUserData());
-            if( pDel )
-                delete pDel;
+            delete static_cast<OUString const *>(pEntry->GetUserData());
+            pEntry->SetUserData(NULL);
             pEntry = m_pDictsLB->Next( pEntry );
         }
 
-        if( m_pCheckButtonData )
-            delete m_pCheckButtonData;
+        delete m_pCheckButtonData;
+        m_pCheckButtonData = NULL;
+
         ModalDialog::dispose();
     }
 
@@ -1785,8 +1785,8 @@ namespace svx
 
     void HangulHanjaEditDictDialog::dispose()
     {
-        if( m_pSuggestions )
-            delete m_pSuggestions;
+        delete m_pSuggestions;
+        m_pSuggestions = NULL;
         ModalDialog::dispose();
     }
 
diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx
index f1c7900..ad1e7fa 100644
--- a/cui/source/dialogs/hldocntp.cxx
+++ b/cui/source/dialogs/hldocntp.cxx
@@ -134,11 +134,11 @@ SvxHyperlinkNewDocTp::~SvxHyperlinkNewDocTp ()
 
 void SvxHyperlinkNewDocTp::dispose()
 {
-    for ( sal_uInt16 n=0; n<m_pLbDocTypes->GetEntryCount(); n++ )
+    if (m_pLbDocTypes)
     {
-        DocumentTypeData* pTypeData = static_cast<DocumentTypeData*>(
-                                      m_pLbDocTypes->GetEntryData ( n ));
-        delete pTypeData;
+        for ( sal_uInt16 n=0; n<m_pLbDocTypes->GetEntryCount(); n++ )
+            delete static_cast<DocumentTypeData*>(m_pLbDocTypes->GetEntryData ( n ));
+        m_pLbDocTypes = NULL;
     }
     SvxHyperlinkTabPageBase::dispose();
 }
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index 62fd046..8044423 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -115,6 +115,8 @@ void SvxHyperlinkTabPageBase::dispose()
     maTimer.Stop();
 
     delete mpMarkWnd;
+    mpMarkWnd = NULL;
+
     IconChoicePage::dispose();
 }
 
diff --git a/cui/source/dialogs/iconcdlg.cxx b/cui/source/dialogs/iconcdlg.cxx
index 111499e..0a1c70e 100644
--- a/cui/source/dialogs/iconcdlg.cxx
+++ b/cui/source/dialogs/iconcdlg.cxx
@@ -236,18 +236,24 @@ void IconChoiceDialog::dispose()
         }
         delete pData;
     }
+    maPageList.clear();
 
-    // remove Userdata from Icons
-    for ( sal_uLong i=0; i < m_pIconCtrl->GetEntryCount(); i++)
+    if (m_pIconCtrl)
     {
-        SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry ( i );
-        sal_uInt16* pUserData = static_cast<sal_uInt16*>(pEntry->GetUserData());
-        delete pUserData;
+        // remove Userdata from Icons
+        for ( sal_uLong i=0; i < m_pIconCtrl->GetEntryCount(); i++)
+        {
+            SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry ( i );
+            delete static_cast<sal_uInt16*>(pEntry->GetUserData());
+        }
+        m_pIconCtrl = NULL;
     }
 
-
     delete pRanges;
+    pRanges = NULL;
     delete pOutSet;
+    pOutSet = NULL;
+
     ModalDialog::dispose();
 }
 
diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx
index db36044..4131c40 100644
--- a/cui/source/dialogs/insdlg.cxx
+++ b/cui/source/dialogs/insdlg.cxx
@@ -401,11 +401,10 @@ SvInsertPlugInDialog::~SvInsertPlugInDialog()
 void SvInsertPlugInDialog::dispose()
 {
     delete m_pURL;
+    m_pURL = NULL;
     InsertObjectDialog_Impl::dispose();
 }
 
-
-
 static void Plugin_ImplFillCommandSequence( const OUString& aCommands, uno::Sequence< beans::PropertyValue >& aCommandSequence )
 {
     sal_Int32 nEaten;
diff --git a/cui/source/dialogs/multipat.cxx b/cui/source/dialogs/multipat.cxx
index 6b4b4b7..ebb8fcd 100644
--- a/cui/source/dialogs/multipat.cxx
+++ b/cui/source/dialogs/multipat.cxx
@@ -237,6 +237,8 @@ void SvxMultiPathDialog::dispose()
     }
 
     delete m_pRadioLB;
+    m_pRadioLB = NULL;
+
     ModalDialog::dispose();
 }
 
@@ -247,10 +249,13 @@ SvxPathSelectDialog::~SvxPathSelectDialog()
 
 void SvxPathSelectDialog::dispose()
 {
-    sal_uInt16 nPos = m_pPathLB->GetEntryCount();
-    while ( nPos-- )
-        delete static_cast<OUString*>(m_pPathLB->GetEntryData(nPos));
-
+    if (m_pPathLB)
+    {
+        sal_uInt16 nPos = m_pPathLB->GetEntryCount();
+        while ( nPos-- )
+            delete static_cast<OUString*>(m_pPathLB->GetEntryData(nPos));
+        m_pPathLB = NULL;
+    }
     ModalDialog::dispose();
 }
 
diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx
index da6a1e6..bb797e3 100644
--- a/cui/source/dialogs/srchxtra.cxx
+++ b/cui/source/dialogs/srchxtra.cxx
@@ -70,6 +70,7 @@ SvxSearchFormatDialog::~SvxSearchFormatDialog()
 void SvxSearchFormatDialog::dispose()
 {
     delete m_pFontList;
+    m_pFontList = NULL;
     SfxTabDialog::dispose();
 }
 
diff --git a/cui/source/options/certpath.cxx b/cui/source/options/certpath.cxx
index 0cfb700..8e47763 100644
--- a/cui/source/options/certpath.cxx
+++ b/cui/source/options/certpath.cxx
@@ -157,6 +157,7 @@ void CertPathDialog::dispose()
         pEntry = m_pCertPathList->Next( pEntry );
     }
     delete m_pCertPathList;
+    m_pCertPathList = NULL;
     ModalDialog::dispose();
 }
 
diff --git a/cui/source/options/dbregister.cxx b/cui/source/options/dbregister.cxx
index eb2364e..de08fa0 100644
--- a/cui/source/options/dbregister.cxx
+++ b/cui/source/options/dbregister.cxx
@@ -171,6 +171,7 @@ void DbRegistrationOptionsPage::dispose()
     for ( sal_uInt16 i = 0; i < pPathBox->GetEntryCount(); ++i )
         delete static_cast< DatabaseRegistration* >( pPathBox->GetEntry(i)->GetUserData() );
     delete pPathBox;
+    pPathBox = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/options/fontsubs.cxx b/cui/source/options/fontsubs.cxx
index c135ab2..098855a 100644
--- a/cui/source/options/fontsubs.cxx
+++ b/cui/source/options/fontsubs.cxx
@@ -144,8 +144,11 @@ SvxFontSubstTabPage::~SvxFontSubstTabPage()
 void SvxFontSubstTabPage::dispose()
 {
     delete pCheckButtonData;
+    pCheckButtonData = NULL;
     delete pConfig;
+    pConfig = NULL;
     delete m_pCheckLB;
+    m_pCheckLB = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/options/optaccessibility.cxx b/cui/source/options/optaccessibility.cxx
index 8deb9e7..f09b19c 100644
--- a/cui/source/options/optaccessibility.cxx
+++ b/cui/source/options/optaccessibility.cxx
@@ -64,6 +64,7 @@ SvxAccessibilityOptionsTabPage::~SvxAccessibilityOptionsTabPage()
 void SvxAccessibilityOptionsTabPage::dispose()
 {
     delete m_pImpl;
+    m_pImpl = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/options/optasian.cxx b/cui/source/options/optasian.cxx
index f8658bd..0f9bab2 100644
--- a/cui/source/options/optasian.cxx
+++ b/cui/source/options/optasian.cxx
@@ -157,6 +157,7 @@ SvxAsianLayoutPage::~SvxAsianLayoutPage()
 void SvxAsianLayoutPage::dispose()
 {
     delete pImpl;
+    pImpl = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx
index 8f8fd97..8005483 100644
--- a/cui/source/options/optchart.cxx
+++ b/cui/source/options/optchart.cxx
@@ -89,11 +89,16 @@ SvxDefaultColorOptPage::~SvxDefaultColorOptPage()
 void SvxDefaultColorOptPage::dispose()
 {
     // save changes
-    pChartOptions->SetDefaultColors( pColorConfig->GetColorList() );
-    pChartOptions->Commit();
+    if (pChartOptions)
+    {
+        pChartOptions->SetDefaultColors( pColorConfig->GetColorList() );
+        pChartOptions->Commit();
 
-    delete pColorConfig;
-    delete pChartOptions;
+        delete pColorConfig;
+        pColorConfig = NULL;
+        delete pChartOptions;
+        pChartOptions = NULL;
+    }
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx
index c96cb62..b18abcc 100644
--- a/cui/source/options/optcolor.cxx
+++ b/cui/source/options/optcolor.cxx
@@ -1077,23 +1077,29 @@ SvxColorOptionsTabPage::~SvxColorOptionsTabPage()
 
 void SvxColorOptionsTabPage::dispose()
 {
-    //when the dialog is cancelled but the color scheme ListBox has been changed these
-    //changes need to be undone
-    if(!bFillItemSetCalled && m_pColorSchemeLB->IsValueChangedFromSaved())
+    if (pColorConfig)
     {
-        OUString sOldScheme =  m_pColorSchemeLB->GetEntry(m_pColorSchemeLB->GetSavedValue());
-        if(!sOldScheme.isEmpty())
+        //when the dialog is cancelled but the color scheme ListBox has been changed these
+        //changes need to be undone
+        if(!bFillItemSetCalled && m_pColorSchemeLB->IsValueChangedFromSaved())
         {
-            pColorConfig->SetCurrentSchemeName(sOldScheme);
-            pExtColorConfig->SetCurrentSchemeName(sOldScheme);
+            OUString sOldScheme =  m_pColorSchemeLB->GetEntry(m_pColorSchemeLB->GetSavedValue());
+            if(!sOldScheme.isEmpty())
+            {
+                pColorConfig->SetCurrentSchemeName(sOldScheme);
+                pExtColorConfig->SetCurrentSchemeName(sOldScheme);
+            }
         }
+        pColorConfig->ClearModified();
+        pColorConfig->EnableBroadcast();
+        delete pColorConfig;
+        pColorConfig = NULL;
+
+        pExtColorConfig->ClearModified();
+        pExtColorConfig->EnableBroadcast();
+        delete pExtColorConfig;
+        pExtColorConfig = NULL;
     }
-    pColorConfig->ClearModified();
-    pColorConfig->EnableBroadcast();
-    delete pColorConfig;
-    pExtColorConfig->ClearModified();
-    pExtColorConfig->EnableBroadcast();
-    delete pExtColorConfig;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx
index 59262aa..6a6d711 100644
--- a/cui/source/options/optfltr.cxx
+++ b/cui/source/options/optfltr.cxx
@@ -165,7 +165,9 @@ OfaMSFilterTabPage2::~OfaMSFilterTabPage2()
 void OfaMSFilterTabPage2::dispose()
 {
     delete pCheckButtonData;
+    pCheckButtonData = NULL;
     delete m_pCheckLB;
+    m_pCheckLB = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index 09c74e5..3ab3ae8 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -688,8 +688,11 @@ OfaViewTabPage::~OfaViewTabPage()
 void OfaViewTabPage::dispose()
 {
     delete mpDrawinglayerOpt;
+    mpDrawinglayerOpt = NULL;
     delete pCanvasSettings;
+    pCanvasSettings = NULL;
     delete pAppearanceCfg;
+    pAppearanceCfg = NULL;
     SfxTabPage::dispose();
 }
 
@@ -1213,6 +1216,7 @@ OfaLanguagesTabPage::~OfaLanguagesTabPage()
 void OfaLanguagesTabPage::dispose()
 {
     delete pLangConfig;
+    pLangConfig = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx
index 04333b7..a9063ece 100644
--- a/cui/source/options/optinet2.cxx
+++ b/cui/source/options/optinet2.cxx
@@ -628,9 +628,11 @@ SvxSecurityTabPage::~SvxSecurityTabPage()
 void SvxSecurityTabPage::dispose()
 {
     delete mpCertPathDlg;
-
+    mpCertPathDlg = NULL;
     delete mpSecOptions;
+    mpSecOptions = NULL;
     delete mpSecOptDlg;
+    mpSecOptDlg = NULL;
     SfxTabPage::dispose();
 }
 
@@ -980,6 +982,7 @@ SvxEMailTabPage::~SvxEMailTabPage()
 void SvxEMailTabPage::dispose()
 {
     delete pImpl;
+    pImpl = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index 8843f10..5be1b1f 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -208,8 +208,11 @@ SvxJavaOptionsPage::~SvxJavaOptionsPage()
 void SvxJavaOptionsPage::dispose()
 {
     delete m_pJavaList;
+    m_pJavaList = NULL;
     delete m_pParamDlg;
+    m_pParamDlg = NULL;
     delete m_pPathDlg;
+    m_pPathDlg = NULL;
     ClearJavaInfo();
 #if HAVE_FEATURE_JAVA
     std::vector< JavaInfo* >::iterator pIter;
@@ -218,6 +221,7 @@ void SvxJavaOptionsPage::dispose()
         JavaInfo* pInfo = *pIter;
         jfw_freeJavaInfo( pInfo );
     }
+    m_aAddedInfos.clear();
 
     jfw_unlock();
 #endif
@@ -944,14 +948,16 @@ SvxJavaClassPathDlg::~SvxJavaClassPathDlg()
 
 void SvxJavaClassPathDlg::dispose()
 {
-    sal_Int32 i, nCount = m_pPathList->GetEntryCount();
-    for ( i = 0; i < nCount; ++i )
-        delete static_cast< OUString* >( m_pPathList->GetEntryData(i) );
+    if (m_pPathList)
+    {
+        sal_Int32 i, nCount = m_pPathList->GetEntryCount();
+        for ( i = 0; i < nCount; ++i )
+            delete static_cast< OUString* >( m_pPathList->GetEntryData(i) );
+        m_pPathList = NULL;
+    }
     ModalDialog::dispose();
 }
 
-
-
 IMPL_LINK_NOARG(SvxJavaClassPathDlg, AddArchiveHdl_Impl)
 {
     sfx2::FileDialogHelper aDlg( TemplateDescription::FILEOPEN_SIMPLE, 0 );
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index 393f6f7..8e7929e 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -1127,8 +1127,8 @@ SvxLinguTabPage::~SvxLinguTabPage()
 
 void SvxLinguTabPage::dispose()
 {
-    if (pLinguData)
-        delete pLinguData;
+    delete pLinguData;
+    pLinguData = NULL;
     SfxTabPage::dispose();
 }
 
@@ -1904,10 +1904,10 @@ SvxEditModulesDlg::~SvxEditModulesDlg()
 void SvxEditModulesDlg::dispose()
 {
     delete pDefaultLinguData;
+    pDefaultLinguData = NULL;
     ModalDialog::dispose();
 }
 
-
 SvTreeListEntry* SvxEditModulesDlg::CreateEntry( OUString& rTxt, sal_uInt16 nCol )
 {
     SvTreeListEntry* pEntry = new SvTreeListEntry;
diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 8cefe81..94de402 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -252,15 +252,18 @@ SvxPathTabPage::~SvxPathTabPage()
 
 void SvxPathTabPage::dispose()
 {
-    for ( sal_uInt16 i = 0; i < pPathBox->GetEntryCount(); ++i )
-        delete static_cast<PathUserData_Impl*>(pPathBox->GetEntry(i)->GetUserData());
-    delete pPathBox;
+    if ( pPathBox )
+    {
+        for ( sal_uInt16 i = 0; i < pPathBox->GetEntryCount(); ++i )
+            delete static_cast<PathUserData_Impl*>(pPathBox->GetEntry(i)->GetUserData());
+        delete pPathBox;
+        pPathBox = NULL;
+    }
     delete pImpl;
+    pImpl = NULL;
     SfxTabPage::dispose();
 }
 
-
-
 SfxTabPage* SvxPathTabPage::Create( vcl::Window* pParent,
                                     const SfxItemSet* rAttrSet )
 {
diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx
index 12fac31..00d3aff 100644
--- a/cui/source/options/optsave.cxx
+++ b/cui/source/options/optsave.cxx
@@ -205,11 +205,10 @@ SfxSaveTabPage::~SfxSaveTabPage()
 void SvxSaveTabPage::dispose()
 {
     delete pImpl;
+    pImpl = NULL;
     SfxTabPage::dispose();
 }
 
-
-
 SfxTabPage* SfxSaveTabPage::Create( vcl::Window* pParent,
                                     const SfxItemSet* rAttrSet )
 {
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 75311ef..095b6fc 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -558,7 +558,7 @@ OfaTreeOptionsDialog::~OfaTreeOptionsDialog()
 void OfaTreeOptionsDialog::dispose()
 {
     pCurrentPageEntry = NULL;
-    SvTreeListEntry* pEntry = pTreeLB->First();
+    SvTreeListEntry* pEntry = pTreeLB ? pTreeLB->First() : NULL;
     // first children
     while(pEntry)
     {
@@ -596,7 +596,7 @@ void OfaTreeOptionsDialog::dispose()
     }
 
     // and parents
-    pEntry = pTreeLB->First();
+    pEntry = pTreeLB ? pTreeLB->First() : NULL;
     while(pEntry)
     {
         if(!pTreeLB->GetParent(pEntry))
@@ -609,7 +609,9 @@ void OfaTreeOptionsDialog::dispose()
         pEntry = pTreeLB->Next(pEntry);
     }
     delete pColorPageItemSet;
+    pColorPageItemSet = NULL;
     deleteGroupNames();
+    pTreeLB = NULL;
     SfxModalDialog::dispose();
 }
 
diff --git a/cui/source/options/webconninfo.cxx b/cui/source/options/webconninfo.cxx
index 9acfdaf..6628b18 100644
--- a/cui/source/options/webconninfo.cxx
+++ b/cui/source/options/webconninfo.cxx
@@ -148,10 +148,10 @@ WebConnectionInfoDialog::~WebConnectionInfoDialog()
 void WebConnectionInfoDialog::dispose()
 {
     delete m_pPasswordsLB;
+    m_pPasswordsLB = NULL;
     ModalDialog::dispose();
 }
 
-
 IMPL_LINK( WebConnectionInfoDialog, HeaderBarClickedHdl, SvSimpleTable*, pTable )
 {
     m_pPasswordsLB->Resort( NULL == pTable );
diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx
index 1c5587c..7405627 100644
--- a/cui/source/tabpages/align.cxx
+++ b/cui/source/tabpages/align.cxx
@@ -256,6 +256,7 @@ AlignmentTabPage::~AlignmentTabPage()
 void AlignmentTabPage::dispose()
 {
     delete m_pOrientHlp;
+    m_pOrientHlp = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index a35fa19..9ad3cfc 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -474,11 +474,16 @@ OfaSwAutoFmtOptionsPage::~OfaSwAutoFmtOptionsPage()
 
 void OfaSwAutoFmtOptionsPage::dispose()
 {
-    delete static_cast<ImpUserData*>(m_pCheckLB->GetUserData( REPLACE_BULLETS ));
-    delete static_cast<ImpUserData*>(m_pCheckLB->GetUserData( APPLY_NUMBERING ));
-    delete static_cast<ImpUserData*>(m_pCheckLB->GetUserData( MERGE_SINGLE_LINE_PARA ));
-    delete pCheckButtonData;
-    delete m_pCheckLB;
+    if (m_pCheckLB)
+    {
+        delete static_cast<ImpUserData*>(m_pCheckLB->GetUserData( REPLACE_BULLETS ));
+        delete static_cast<ImpUserData*>(m_pCheckLB->GetUserData( APPLY_NUMBERING ));
+        delete static_cast<ImpUserData*>(m_pCheckLB->GetUserData( MERGE_SINGLE_LINE_PARA ));
+        delete pCheckButtonData;
+        pCheckButtonData = NULL;
+        delete m_pCheckLB;
+        m_pCheckLB = NULL;
+    }
     SfxTabPage::dispose();
 }
 
@@ -912,7 +917,9 @@ void OfaAutocorrReplacePage::dispose()
     aChangesTable.clear();
 
     delete pCompareClass;
+    pCompareClass = NULL;
     delete pCharClass;
+    pCharClass = NULL;
     SfxTabPage::dispose();
 }
 
@@ -1841,7 +1848,9 @@ OfaQuoteTabPage::~OfaQuoteTabPage()
 void OfaQuoteTabPage::dispose()
 {
     delete pCheckButtonData;
+    pCheckButtonData = NULL;
     delete m_pSwCheckLB;
+    m_pSwCheckLB = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 2945304..15c7826 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -237,10 +237,10 @@ BackgroundPreviewImpl::~BackgroundPreviewImpl()
 void BackgroundPreviewImpl::dispose()
 {
     delete pBitmap;
+    pBitmap = NULL;
     vcl::Window::dispose();
 }
 
-
 void BackgroundPreviewImpl::NotifyChange( const Color& rColor )
 {
     if ( !bIsBmp )
@@ -434,9 +434,15 @@ SvxBackgroundTabPage::~SvxBackgroundTabPage()
 
 void SvxBackgroundTabPage::dispose()
 {
-    delete pPageImpl->pLoadIdle;
-    delete pPageImpl;
+    if (pPageImpl)
+    {
+        delete pPageImpl->pLoadIdle;
+        delete pPageImpl;
+        pPageImpl = NULL;
+    }
+
     delete pImportDlg;
+    pImportDlg = NULL;
 
     if( pTableBck_Impl)
     {
@@ -444,6 +450,7 @@ void SvxBackgroundTabPage::dispose()
         delete pTableBck_Impl->pRowBrush;
         delete pTableBck_Impl->pTableBrush;
         delete pTableBck_Impl;
+        pTableBck_Impl = NULL;
     }
 
     if(pParaBck_Impl)
@@ -451,6 +458,7 @@ void SvxBackgroundTabPage::dispose()
         delete pParaBck_Impl->pParaBrush;
         delete pParaBck_Impl->pCharBrush;
         delete pParaBck_Impl;
+        pParaBck_Impl = NULL;
     }
     SvxTabPage::dispose();
 }
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index d3fc397..f4c1054 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -375,11 +375,10 @@ SvxCharNamePage::~SvxCharNamePage()
 void SvxCharNamePage::dispose()
 {
     delete m_pImpl;
+    m_pImpl = NULL;
     SvxCharBasePage::dispose();
 }
 
-
-
 void SvxCharNamePage::Initialize()
 {
     // to handle the changes of the other pages
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index f80c0d8..cab5ff2 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -289,7 +289,9 @@ SvxNumberFormatTabPage::~SvxNumberFormatTabPage()
 void SvxNumberFormatTabPage::dispose()
 {
     delete pNumFmtShell;
+    pNumFmtShell = NULL;
     delete pNumItem;
+    pNumItem = NULL;
     SfxTabPage::dispose();
 }
 
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 7ffcd79..56d500e 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -225,7 +225,9 @@ SvxSingleNumPickTabPage::~SvxSingleNumPickTabPage()
 void SvxSingleNumPickTabPage::dispose()
 {
     delete pActNum;
+    pActNum = NULL;
     delete pSaveNum;
+    pSaveNum = NULL;
     SfxTabPage::dispose();
 }
 
@@ -392,7 +394,9 @@ SvxBulletPickTabPage::~SvxBulletPickTabPage()
 void SvxBulletPickTabPage::dispose()
 {
     delete pActNum;
+    pActNum = NULL;
     delete pSaveNum;
+    pSaveNum = NULL;
     SfxTabPage::dispose();
 }
 
@@ -595,7 +599,9 @@ SvxNumPickTabPage::~SvxNumPickTabPage()
 void SvxNumPickTabPage::dispose()
 {
     delete pActNum;
+    pActNum = NULL;
     delete pSaveNum;
+    pSaveNum = NULL;
     SfxTabPage::dispose();
 }
 
@@ -842,7 +848,9 @@ SvxBitmapPickTabPage::~SvxBitmapPickTabPage()
 void SvxBitmapPickTabPage::dispose()
 {
     delete pActNum;
+    pActNum = NULL;
     delete pSaveNum;
+    pSaveNum = NULL;
     SfxTabPage::dispose();
 }
 
@@ -1154,9 +1162,15 @@ SvxNumOptionsTabPage::~SvxNumOptionsTabPage()
 
 void SvxNumOptionsTabPage::dispose()
 {
-    delete m_pBitmapMB->GetPopupMenu()->GetPopupMenu(m_nGalleryId);
+    if (m_pBitmapMB)
+    {
+        delete m_pBitmapMB->GetPopupMenu()->GetPopupMenu(m_nGalleryId);
+        m_pBitmapMB = NULL;
+    }
     delete pActNum;
+    pActNum = NULL;
     delete pSaveNum;
+    pSaveNum = NULL;
     SfxTabPage::dispose();
 }
 
@@ -2719,9 +2733,12 @@ SvxNumPositionTabPage::~SvxNumPositionTabPage()
 void SvxNumPositionTabPage::dispose()
 {
     delete pActNum;
+    pActNum = NULL;
     delete pSaveNum;
+    pSaveNum = NULL;
     SfxTabPage::dispose();
 }
+
 /*-------------------------------------------------------*/
 
 #if OSL_DEBUG_LEVEL > 1
diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx
index 13f87f7..6c8c41e 100644
--- a/cui/source/tabpages/page.cxx
+++ b/cui/source/tabpages/page.cxx
@@ -374,6 +374,8 @@ void SvxPageDescPage::dispose()
     if(mbDelPrinter)
     {
         delete mpDefPrinter;
+        mpDefPrinter = NULL;
+        mbDelPrinter = false;
     }
     SfxTabPage::dispose();
 }
diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx
index 3a81c3d..faf565c 100644
--- a/cui/source/tabpages/tpbitmap.cxx
+++ b/cui/source/tabpages/tpbitmap.cxx
@@ -128,11 +128,10 @@ SvxBitmapTabPage::~SvxBitmapTabPage()
 void SvxBitmapTabPage::dispose()
 {
     delete m_pBitmapCtl;
+    m_pBitmapCtl = NULL;
     SvxTabPage::dispose();
 }
 
-
-
 void SvxBitmapTabPage::Construct()
 {
     m_pLbColor->Fill( pColorList );
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index a9dd014..3d74649 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -403,11 +403,10 @@ SvxColorTabPage::~SvxColorTabPage()
 void SvxColorTabPage::dispose()
 {
     delete pShadow;
+    pShadow = NULL;
     SfxTabPage::dispose();
 }
 
-
-
 void SvxColorTabPage::ImpColorCountChanged()
 {
     if (!pColorList.is())
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index eb0cf97..e6fe6a9 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -236,11 +236,14 @@ SvxLineTabPage::~SvxLineTabPage()
 void SvxLineTabPage::dispose()
 {
     // Symbols on a line (e.g. StarCharts), dtor new!
+    if (m_pSymbolMB)
+    {
+        delete m_pSymbolMB->GetPopupMenu()->GetPopupMenu( MN_GALLERY );
 
-    delete m_pSymbolMB->GetPopupMenu()->GetPopupMenu( MN_GALLERY );
-
-    if(pSymbolList)
-        delete m_pSymbolMB->GetPopupMenu()->GetPopupMenu( MN_SYMBOLS );
+        if(pSymbolList)
+            delete m_pSymbolMB->GetPopupMenu()->GetPopupMenu( MN_SYMBOLS );
+        m_pSymbolMB = NULL;
+    }
 
     for ( size_t i = 0, n = aGrfBrushItems.size(); i < n; ++i )
     {
@@ -248,6 +251,8 @@ void SvxLineTabPage::dispose()
         delete pInfo->pBrushItem;
         delete pInfo;
     }
+    aGrfBrushItems.clear();
+
     SvxTabPage::dispose();
 }
 
diff --git a/fpicker/source/office/PlacesListBox.cxx b/fpicker/source/office/PlacesListBox.cxx
index 35d84aa..23dfa0f 100644
--- a/fpicker/source/office/PlacesListBox.cxx
+++ b/fpicker/source/office/PlacesListBox.cxx
@@ -94,8 +94,11 @@ PlacesListBox::~PlacesListBox( )
 void PlacesListBox::dispose()
 {
     delete mpImpl;
+    mpImpl = NULL;
     delete mpAddBtn;
+    mpAddBtn = NULL;
     delete mpDelBtn;
+    mpDelBtn = NULL;
     Control::dispose();
 }
 
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 0637d7d..e624ad6 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -511,14 +511,13 @@ SfxFloatingWindow::~SfxFloatingWindow()
 
 void SfxFloatingWindow::dispose()
 {
-    if ( pImp->pMgr->GetFrame() == pBindings->GetActiveFrame() )
+    if ( pImp && pImp->pMgr->GetFrame() == pBindings->GetActiveFrame() )
         pBindings->SetActiveFrame( NULL );
     delete pImp;
+    pImp = NULL;
     FloatingWindow::dispose();
 }
 
-
-
 void SfxFloatingWindow::Resize()
 
 /*  [Description]
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 3a496f0..3d4ac23 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -136,9 +136,13 @@ void SmEditWindow::dispose()
     // must be done before EditView (and thus EditEngine) is no longer
     // available for those classes.
     if (pAccessible)
+    {
         pAccessible->ClearWin();    // make Accessible defunctional
+        pAccessible = NULL;
+        xAccessible.clear();
+    }
     // Note: memory for pAccessible will be freed when the reference
-    // xAccessible is released.
+    // xAccessible is released. FIXME: horribly redundant lifecycle ! ...
 
     if (pEditView)
     {
@@ -157,6 +161,7 @@ void SmEditWindow::dispose()
     pVScrollBar = NULL;
     delete pScrollBox;
     pScrollBox = NULL;
+
     vcl::Window::dispose();
 }
 
diff --git a/starmath/source/toolbox.cxx b/starmath/source/toolbox.cxx
index 01d4994..f396b5c 100644
--- a/starmath/source/toolbox.cxx
+++ b/starmath/source/toolbox.cxx
@@ -149,9 +149,14 @@ void SmToolBoxWindow::dispose()
     {
         ToolBox *pBox = vToolBoxCategories[i];
         delete pBox;
+        vToolBoxCategories[i] = 0;
     }
+    pToolBoxCmd = 0;
     for (i = 0;  i < NUM_TBX_CATEGORIES + 1;  ++i)
+    {
         delete aImageLists[i];
+        aImageLists[i] = 0;
+    }
     SfxFloatingWindow::dispose();
 }
 
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx
index 5b5de37..49fb3aa 100644
--- a/svtools/source/brwbox/brwbox1.cxx
+++ b/svtools/source/brwbox/brwbox1.cxx
@@ -781,7 +781,6 @@ void BrowseBox::RemoveColumn( sal_uInt16 nItemId )
 
 void BrowseBox::RemoveColumns()
 {
-
     size_t nOldCount = pCols->size();
 
     // remove all columns
diff --git a/svtools/source/control/headbar.cxx b/svtools/source/control/headbar.cxx
index be8b574..87e019d 100644
--- a/svtools/source/control/headbar.cxx
+++ b/svtools/source/control/headbar.cxx
@@ -119,17 +119,16 @@ HeaderBar::~HeaderBar()
 
 void HeaderBar::dispose()
 {
-    // Alle Items loeschen
-    for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
-        delete (*mpItemList)[ i ];
+    if (mpItemList)
+    {
+        for ( size_t i = 0, n = mpItemList->size(); i < n; ++i )
+            delete (*mpItemList)[ i ];
+        delete mpItemList;
+        mpItemList = NULL;
     }
-    mpItemList->clear();
-    delete mpItemList;
     Window::dispose();
 }
 
-
-
 void HeaderBar::ImplInitSettings( bool bFont,
                                   bool bForeground, bool bBackground )
 {
diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
index 9542c99..f704de3 100644
--- a/svx/source/dialog/docrecovery.cxx
+++ b/svx/source/dialog/docrecovery.cxx
@@ -909,6 +909,7 @@ RecoveryDialog::~RecoveryDialog()
 void RecoveryDialog::dispose()
 {
     delete m_pFileListLB;
+    m_pFileListLB = NULL;
     Dialog::dispose();
 }
 
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index 860c6ac..e1ed4af 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -141,7 +141,7 @@ void FmGridHeader::dispose()
 {
     delete m_pImpl;
     m_pImpl = NULL;
-    FmGridHeader::dispose();
+    svt::EditBrowserHeader::dispose();
 }
 
 sal_uInt16 FmGridHeader::GetModelColumnPos(sal_uInt16 nId) const
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index a60522a..89caf26 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -956,9 +956,10 @@ DbGridControl::~DbGridControl()
 
 void DbGridControl::dispose()
 {
-    RemoveColumns();
-
+    if (!IsDisposed())
     {
+        RemoveColumns();
+
         m_bWantDestruction = true;
         osl::MutexGuard aGuard(m_aDestructionSafety);
         if (m_pFieldListeners)
@@ -984,7 +985,9 @@ void DbGridControl::dispose()
     m_xRowSetListener.clear();
 
     delete m_pDataCursor;
+    m_pDataCursor = NULL;
     delete m_pSeekCursor;
+    m_pSeekCursor = NULL;
 
     m_aBar.disposeAndClear();
 
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 0d2893c..7af4b3b 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -2262,7 +2262,7 @@ SwViewShell::CreateAccessiblePreview()
 
 void SwViewShell::InvalidateAccessibleFocus()
 {
-    if( Imp() && Imp()->IsAccessible() )
+    if( this && Imp() && Imp()->IsAccessible() )
         Imp()->GetAccessibleMap().InvalidateFocus();
 }
 
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 20a43c0..1e2b292 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -5082,7 +5082,7 @@ void SwEditWin::LoseFocus()
 {
     m_rView.GetWrtShell().InvalidateAccessibleFocus();
     Window::LoseFocus();
-    if( m_pQuickHlpData->m_bIsDisplayed )
+    if( m_pQuickHlpData && m_pQuickHlpData->m_bIsDisplayed )
         m_pQuickHlpData->Stop( m_rView.GetWrtShell() );
 }
 
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 1fffd48..7861656 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -96,13 +96,11 @@ Button::Button( WindowType nType ) :
 Button::~Button()
 {
     dispose();
+    delete mpButtonData;
 }
 
 void Button::dispose()
 {
-    delete mpButtonData;
-    mpButtonData = NULL;
-
     Control::dispose();
 }
 
@@ -543,7 +541,7 @@ sal_uInt16& Button::ImplGetButtonState()
 
 sal_uInt16 Button::ImplGetButtonState() const
 {
-    return mpButtonData->mnButtonState;
+    return mpButtonData ? mpButtonData->mnButtonState : 0;
 }
 
 void Button::ImplSetSymbolAlign( SymbolAlign eAlign )
@@ -1588,7 +1586,8 @@ void PushButton::SetPressed( bool bPressed )
 void PushButton::EndSelection()
 {
     EndTracking( ENDTRACK_CANCEL );
-    if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
+    if ( !IsDisposed() &&
+         ImplGetButtonState() & BUTTON_DRAW_PRESSED )
     {
         ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
         if ( !mbPressed )
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 73987a1..4a89c0f 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -206,9 +206,9 @@ void TabControl::dispose()
     // delete TabCtrl data
     if ( mpTabCtrlData )
     {
-        if( mpTabCtrlData->mpListBox )
-            delete mpTabCtrlData->mpListBox;
+        delete mpTabCtrlData->mpListBox;
         delete mpTabCtrlData;
+        mpTabCtrlData = NULL;
     }
     Control::dispose();
 }
diff --git a/vcl/source/window/accessibility.cxx b/vcl/source/window/accessibility.cxx
index fc3dc74..ca88656 100644
--- a/vcl/source/window/accessibility.cxx
+++ b/vcl/source/window/accessibility.cxx
@@ -136,6 +136,8 @@ namespace vcl {
             return pChild->GetAccessible();
     }
     */
+    if ( !mpWindowImpl )
+        return css::uno::Reference< css::accessibility::XAccessible >();
     if ( !mpWindowImpl->mxAccessible.is() && bCreate )
         mpWindowImpl->mxAccessible = CreateAccessible();
 
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 9975c97..b34a451 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -347,8 +347,8 @@ void Dialog::ImplInitDialogData()
     mbOldSaveBack           = false;
     mbInClose               = false;
     mbModalMode             = false;
-    mpContentArea.disposeAndClear();
-    mpActionArea.disposeAndClear();
+    mpContentArea.clear();
+    mpActionArea.clear();
     mnMousePositioned       = 0;
     mpDialogImpl            = new DialogImpl;
 }
@@ -551,8 +551,8 @@ void Dialog::dispose()
 {
     delete mpDialogImpl;
     mpDialogImpl = NULL;
-    mpActionArea.disposeAndClear();
-    mpContentArea.disposeAndClear();
+    mpActionArea.clear();
+    mpContentArea.clear();
     SystemWindow::dispose();
 }
 
commit e8284454f517d29a29f95a347a38730ded047f41
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Feb 28 19:59:01 2015 +0000

    Double dispose protection.
    
    Change-Id: Iadc0a4fcb711e4f846e0e047880e512c9d42d0f8

diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx
index cec82ca..4a37ec3 100644
--- a/chart2/source/controller/main/ChartWindow.cxx
+++ b/chart2/source/controller/main/ChartWindow.cxx
@@ -84,6 +84,7 @@ void ChartWindow::dispose()
         x3DWindowProvider->update();
     }
     delete m_pOpenGLWindow;
+    m_pOpenGLWindow = NULL;
     vcl::Window::dispose();
 }
 
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index 0ad429b..860c6ac 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -140,6 +140,7 @@ FmGridHeader::~FmGridHeader()
 void FmGridHeader::dispose()
 {
     delete m_pImpl;
+    m_pImpl = NULL;
     FmGridHeader::dispose();
 }
 
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 14dfb43..0d2893c 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -2262,7 +2262,7 @@ SwViewShell::CreateAccessiblePreview()
 
 void SwViewShell::InvalidateAccessibleFocus()
 {
-    if( Imp()->IsAccessible() )
+    if( Imp() && Imp()->IsAccessible() )
         Imp()->GetAccessibleMap().InvalidateFocus();
 }
 
diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index 137ca04..4cec1d0 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -113,7 +113,7 @@ void Control::CreateLayoutData() const
 
 bool Control::HasLayoutData() const
 {
-    return mpControlData->mpLayoutData != NULL;
+    return mpControlData ? mpControlData->mpLayoutData != NULL : false;
 }
 
 ::vcl::ControlLayoutData* Control::GetLayoutData() const
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index 23da0e8..31fcb3a 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -84,8 +84,12 @@ void ListBox::dispose()
     delete pImplLB;
 
     delete mpFloatWin;
+    mpFloatWin = NULL;
     delete mpImplWin;
+    mpImplWin = NULL;
     delete mpBtn;
+    mpBtn = NULL;
+
     Control::dispose();
 }
 
commit cffa7dd2f2eab7f3430519e91f0ccb00fdc3b5f5
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Feb 28 17:34:47 2015 +0000

    calc: double dispose issue.
    
    Change-Id: Ic8cc713ef2c7ec77d5418df5b5b689406641b037

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 4e32f8c..f04a482 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1508,7 +1508,10 @@ void ScTextWnd::dispose()
         maAccTextDatas.back()->Dispose();
     }
     delete pEditView;
+    pEditView = NULL;
     delete pEditEngine;
+    pEditEngine = NULL;
+
     ScTextWndBase::dispose();
 }
 
commit d0cc0d3735b9ada26ee7b3d54b82a3ed60bc4a74
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Feb 28 09:54:57 2015 +0000

    more double dispose protection.
    
    Change-Id: I729040288868ad521cc1ff09e200ef7ea3bd0058

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index a5b8c88e..4e32f8c 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -289,6 +289,9 @@ void ScInputWindow::dispose()
     SfxImageManager::GetImageManager( *SC_MOD() )->ReleaseToolBox( this );
 
     aWndPos.disposeAndClear();
+
+    pRuntimeWindow.reset();
+
     ToolBox::dispose();
 }
 
diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx
index f5a7643..4d9f9f4 100644
--- a/sfx2/source/sidebar/SidebarToolBox.cxx
+++ b/sfx2/source/sidebar/SidebarToolBox.cxx
@@ -81,7 +81,9 @@ void SidebarToolBox::dispose()
         SetSelectHdl(Link());
         SetActivateHdl(Link());
         SetDeactivateHdl(Link());
+        mbAreHandlersRegistered = false;
     }
+
     ToolBox::dispose();
 }
 
commit 562109b8357eb0690034844e097e0acafbdc39b6
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Feb 27 16:29:46 2015 +0000

    vcl: ensure that VclBuilder is disposed before parent window.
    
    Move VclBuilder to use VclPtr, link to documentation, and fix more
    double dispose issues.
    
    Change-Id: I4900b69dbb381bd7d6fda97f2a5e623bb58e0a9f

diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx
index 3eb0229..c96cb62 100644
--- a/cui/source/options/optcolor.cxx
+++ b/cui/source/options/optcolor.cxx
@@ -174,6 +174,8 @@ class ColorConfigWindow_Impl
 {
 public:
     ColorConfigWindow_Impl(vcl::Window* pParent);
+    ~ColorConfigWindow_Impl() { dispose(); }
+    virtual void dispose() SAL_OVERRIDE;
 
 public:
     void SetLinks (Link const&, Link const&, Link const&);
@@ -508,6 +510,12 @@ ColorConfigWindow_Impl::ColorConfigWindow_Impl(vcl::Window* pParent)
     SetAppearance();
 }
 
+void ColorConfigWindow_Impl::dispose()
+{
+    disposeBuilder();
+    VclContainer::dispose();
+}
+
 Size ColorConfigWindow_Impl::calculateRequisition() const
 {
     return getLayoutRequisition(*m_pGrid);
@@ -913,9 +921,14 @@ ColorConfigCtrl_Impl::~ColorConfigCtrl_Impl()
 void ColorConfigCtrl_Impl::dispose()
 {
     delete m_pVScroll;
+    m_pVScroll = NULL;
     delete m_pScrollWindow;
+    m_pScrollWindow = NULL;
     delete m_pBody;
+    m_pBody = NULL;
     delete m_pHeaderHB;
+    m_pHeaderHB = NULL;
+
     VclVBox::dispose();
 }
 
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 179ca33..aba3f08 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -16,6 +16,7 @@
 #include <tools/fldunit.hxx>
 #include <vcl/dllapi.h>
 #include <vcl/window.hxx>
+#include <vcl/vclptr.hxx>
 #include <map>
 #include <set>
 #include <stack>
@@ -55,6 +56,9 @@ public:
                             const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
                     ~VclBuilder();
 
+    ///releases references and disposes all children.
+    void disposeBuilder();
+
     //sID must exist and be of type T
     template <typename T> T* get(T*& ret, const OString& sID);
 
@@ -146,7 +150,7 @@ private:
     struct WinAndId
     {
         OString m_sID;
-        vcl::Window *m_pWindow;
+        VclPtr<vcl::Window> m_pWindow;
         short m_nResponseId;
         PackingData m_aPackingData;
         WinAndId(const OString &rId, vcl::Window *pWindow, bool bVertical)
@@ -445,12 +449,17 @@ inline PopupMenu* VclBuilder::get_menu(PopupMenu*& ret, const OString& sID)
 //
 //i.e.  class Dialog : public SystemWindow, public VclBuilderContainer
 //not   class Dialog : public VclBuilderContainer, public SystemWindow
+//
+//With the new 'dispose' framework, it is necessary to force the builder
+//dispose before the Window dispose; so a Dialog::dispose() method would
+//finish: disposeBuilder(); SystemWindow::dispose() to capture this ordering.
 
 class VCL_DLLPUBLIC VclBuilderContainer
 {
 public:
                     VclBuilderContainer();
     virtual         ~VclBuilderContainer();
+    void            disposeBuilder();
 
     static OUString getUIRootDir();
     bool            hasBuilder() const { return m_pUIBuilder != NULL; }
diff --git a/include/vcl/tabpage.hxx b/include/vcl/tabpage.hxx
index c736197..7294d48 100644
--- a/include/vcl/tabpage.hxx
+++ b/include/vcl/tabpage.hxx
@@ -41,6 +41,8 @@ private:
 public:
     explicit        TabPage( vcl::Window* pParent, WinBits nStyle = 0 );
     explicit        TabPage( vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription );
+                   ~TabPage();
+    virtual void    dispose() SAL_OVERRIDE;
 
     virtual void    Paint( const Rectangle& rRect ) SAL_OVERRIDE;
     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index 37da714..50a87ba 100644
--- a/include/vcl/vclptr.hxx
+++ b/include/vcl/vclptr.hxx
@@ -70,6 +70,9 @@ public:
 
 /**
  * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses.
+ *
+ * For more details on the design please see vcl/README.lifecycle
+ *
  * @param reference_type must be a subclass of vcl::Window
  */
 template <class reference_type>
@@ -136,6 +139,11 @@ public:
         m_rInnerRef.set(pBody);
     }
 
+    inline void SAL_CALL reset(reference_type *pBody)
+    {
+        m_rInnerRef.set(pBody);
+    }
+
     inline VclPtr<reference_type>& SAL_CALL operator= (reference_type * pBody)
     {
         m_rInnerRef.set(pBody);
@@ -152,6 +160,16 @@ public:
         return m_rInnerRef.get() != NULL;
     }
 
+    inline void SAL_CALL clear()
+    {
+        m_rInnerRef.clear();
+    }
+
+    inline void SAL_CALL reset()
+    {
+        m_rInnerRef.clear();
+    }
+
     inline void disposeAndClear()
     {
         // hold it alive for the lifetime of this method
diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx
index c5e131a..fb86522 100644
--- a/reportdesign/source/ui/dlg/Condition.cxx
+++ b/reportdesign/source/ui/dlg/Condition.cxx
@@ -162,6 +162,7 @@ OColorPopup::~OColorPopup()
 void OColorPopup::dispose()
 {
     m_aColorSet.disposeAndClear();
+    disposeBuilder();
     FloatingWindow::dispose();
 }
 
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 9a80a2e..78c2df2 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -1457,6 +1457,9 @@ void SfxHelpIndexWindow_Impl::dispose()
 
     SvtViewOptions aViewOpt( E_TABDIALOG, CONFIGNAME_INDEXWIN );
     aViewOpt.SetPageID( (sal_Int32)m_pTabCtrl->GetCurPageId() );
+
+    disposeBuilder();
+
     vcl::Window::dispose();
 }
 
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index fa3f403..fcb9074 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -217,6 +217,7 @@ void BackingWindow::dispose()
         }
         mxDropTargetListener = css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >();
     }
+    disposeBuilder();
     vcl::Window::dispose();
 }
 
diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx
index c3e0e3d..e17c3b2 100644
--- a/sfx2/source/dialog/dockwin.cxx
+++ b/sfx2/source/dialog/dockwin.cxx
@@ -259,6 +259,8 @@ SfxTitleDockingWindow::~SfxTitleDockingWindow()
 void SfxTitleDockingWindow::dispose()
 {
     delete m_pWrappedWindow;
+    m_pWrappedWindow = NULL;
+
     SfxDockingWindow::dispose();
 }
 
diff --git a/svx/source/dialog/ctredlin.cxx b/svx/source/dialog/ctredlin.cxx
index 48b50b0..0d2e530 100644
--- a/svx/source/dialog/ctredlin.cxx
+++ b/svx/source/dialog/ctredlin.cxx
@@ -118,6 +118,7 @@ SvxRedlinTable::~SvxRedlinTable()
 void SvxRedlinTable::dispose()
 {
     delete pCommentSearcher;
+    pCommentSearcher = NULL;
     SvSimpleTable::dispose();
 }
 
@@ -1084,7 +1085,10 @@ SvxAcceptChgCtr::~SvxAcceptChgCtr()
 void SvxAcceptChgCtr::dispose()
 {
     delete pTPView;
+    pTPView = NULL;
     delete pTPFilter;
+    pTPFilter = NULL;
+    disposeBuilder();
     TabControl::dispose();
 }
 
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
index 148a747..c09637e 100644
--- a/svx/source/form/datanavi.cxx
+++ b/svx/source/form/datanavi.cxx
@@ -1419,17 +1419,23 @@ namespace svxform
         aViewOpt.SetUserItem(CFGNAME_SHOWDETAILS,aAny);
 
         delete m_pInstPage;
+        m_pInstPage = NULL;
         delete m_pSubmissionPage;
+        m_pSubmissionPage = NULL;
         delete m_pBindingPage;
+        m_pBindingPage = NULL;
 
         sal_Int32 i, nCount = m_aPageList.size();
         for ( i = 0; i < nCount; ++i )
             delete m_aPageList[i];
+        m_aPageList.clear();
+
         Reference< XFrameActionListener > xListener(
             static_cast< XFrameActionListener* >( m_xDataListener.get() ), UNO_QUERY );
         m_xFrame->removeFrameActionListener( xListener );
         RemoveBroadcaster();
         m_xDataListener.clear();
+        disposeBuilder();
         vcl::Window::dispose();
     }
 
diff --git a/svx/source/sidebar/PanelLayout.cxx b/svx/source/sidebar/PanelLayout.cxx
index 23934f6..5224725 100644
--- a/svx/source/sidebar/PanelLayout.cxx
+++ b/svx/source/sidebar/PanelLayout.cxx
@@ -33,6 +33,7 @@ void PanelLayout::dispose()
 {
     m_bInClose = true;
     m_aPanelLayoutIdle.Stop();
+    disposeBuilder();
     Control::dispose();
 }
 
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 9bcaa1f..0005136 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -2658,6 +2658,8 @@ void SwTokenWindow::dispose()
         pControl->SetLoseFocusHdl( Link() );
         delete pControl;
     }
+    aControlList.clear();
+    disposeBuilder();
     VclHBox::dispose();
 }
 
diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.cxx b/sw/source/uibase/sidebar/PagePropertyPanel.cxx
index dd2fac9..13db321 100644
--- a/sw/source/uibase/sidebar/PagePropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/PagePropertyPanel.cxx
@@ -206,7 +206,15 @@ PagePropertyPanel::~PagePropertyPanel()
 void PagePropertyPanel::dispose()
 {
     delete[] maImgSize;
+    maImgSize = NULL;
     delete[] maImgSize_L;
+    maImgSize_L = NULL;
+
+    mpPageItem.reset();
+    mpPageLRMarginItem.reset();
+    mpPageULMarginItem.reset();
+    mpPageSizeItem.reset();
+
     PanelLayout::dispose();
 }
 
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 3efccec..278a3e5 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -525,17 +525,24 @@ VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUStr
 
 VclBuilder::~VclBuilder()
 {
+    disposeBuilder();
+}
+
+void VclBuilder::disposeBuilder()
+{
     for (std::vector<WinAndId>::reverse_iterator aI = m_aChildren.rbegin(),
          aEnd = m_aChildren.rend(); aI != aEnd; ++aI)
     {
-        delete aI->m_pWindow;
+        aI->m_pWindow.disposeAndClear();
     }
+    m_aChildren.clear();
 
     for (std::vector<MenuAndId>::reverse_iterator aI = m_aMenus.rbegin(),
          aEnd = m_aMenus.rend(); aI != aEnd; ++aI)
     {
         delete aI->m_pMenu;
     }
+    m_aMenus.clear();
 }
 
 void VclBuilder::handleTranslations(xmlreader::XmlReader &reader)
@@ -3213,7 +3220,7 @@ void VclBuilder::collectAccelerator(xmlreader::XmlReader &reader, stringmap &rMa
 
 vcl::Window *VclBuilder::get_widget_root()
 {
-    return m_aChildren.empty() ? NULL : m_aChildren[0].m_pWindow;
+    return m_aChildren.empty() ? NULL : m_aChildren[0].m_pWindow.get();
 }
 
 vcl::Window *VclBuilder::get_by_name(const OString& sID)
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 8178788..9975c97 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -456,6 +456,12 @@ Dialog::Dialog( WindowType nType )
     ImplInitDialogData();
 }
 
+void VclBuilderContainer::disposeBuilder()
+{
+    if (m_pUIBuilder)
+        m_pUIBuilder->disposeBuilder();
+}
+
 OUString VclBuilderContainer::getUIRootDir()
 {
     /*to-do, check if user config has an override before using shared one, etc*/
diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx
index 549d8c4..bc1740e 100644
--- a/vcl/source/window/dockwin.cxx
+++ b/vcl/source/window/dockwin.cxx
@@ -119,6 +119,9 @@ void ImplDockFloatWin::dispose()
 {
     if( mnLastUserEvent )
         Application::RemoveUserEvent( mnLastUserEvent );
+
+    disposeBuilder();
+
     FloatingWindow::dispose();
 }
 
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index 19768d7..3bc802f 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -118,6 +118,7 @@ void SystemWindow::dispose()
     // Hack to make sure code called from base ~Window does not interpret this
     // as a SystemWindow (which it no longer is by then):
     mpWindowImpl->mbSysWin = false;
+    disposeBuilder();
 
     Window::dispose();
 }
diff --git a/vcl/source/window/tabpage.cxx b/vcl/source/window/tabpage.cxx
index d554964..995438f 100644
--- a/vcl/source/window/tabpage.cxx
+++ b/vcl/source/window/tabpage.cxx
@@ -85,6 +85,17 @@ TabPage::TabPage(vcl::Window *pParent, const OString& rID, const OUString& rUIXM
     set_expand(true);
 }
 
+TabPage::~TabPage()
+{
+    dispose();
+}
+
+void TabPage::dispose()
+{
+    disposeBuilder();
+    vcl::Window::dispose();
+}
+
 void TabPage::StateChanged( StateChangedType nType )
 {
     Window::StateChanged( nType );
commit 292990396aefdae15b91f2df395da4b52d5e3f6a
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Feb 27 15:39:58 2015 +0000

    sw: more double dispose work.
    
    Change-Id: I746623d14a96bb1b2756e49da4d41adf9dbc55ca

diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx
index ed975eb..8d17283 100644
--- a/reportdesign/source/ui/report/DesignView.cxx
+++ b/reportdesign/source/ui/report/DesignView.cxx
@@ -206,7 +206,7 @@ bool ODesignView::PreNotify( NotifyEvent& rNEvt )
                     const vcl::KeyCode& rCode = pKeyEvent->GetKeyCode();
                     util::URL aUrl;
                     aUrl.Complete = m_pAccel->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rCode));
-                    if ( aUrl.Complete.isEmpty() || !m_rController.isCommandEnabled( aUrl.Complete ) )
+                    if ( aUrl.Complete.isEmpty() || !m_xController->isCommandEnabled( aUrl.Complete ) )
                         nRet = false;
                 }
             }
diff --git a/sw/source/uibase/docvw/FrameControlsManager.cxx b/sw/source/uibase/docvw/FrameControlsManager.cxx
index 7cd0e7f..e168096 100644
--- a/sw/source/uibase/docvw/FrameControlsManager.cxx
+++ b/sw/source/uibase/docvw/FrameControlsManager.cxx
@@ -34,6 +34,11 @@ SwFrameControlsManager::SwFrameControlsManager( const SwFrameControlsManager& rC
 {
 }
 
+void SwFrameControlsManager::dispose()
+{
+    m_aControls.clear();
+}
+
 const SwFrameControlsManager& SwFrameControlsManager::operator=( const SwFrameControlsManager& rCopy )
 {
     m_pEditWin = rCopy.m_pEditWin;
diff --git a/sw/source/uibase/docvw/PageBreakWin.cxx b/sw/source/uibase/docvw/PageBreakWin.cxx
index d13b4b1..01d95ba 100644
--- a/sw/source/uibase/docvw/PageBreakWin.cxx
+++ b/sw/source/uibase/docvw/PageBreakWin.cxx
@@ -124,9 +124,13 @@ void SwPageBreakWin::dispose()
     m_bDestroyed = true;
     m_aFadeTimer.Stop();
 
-    delete m_pPopupMenu;
     delete m_pLine;
+    m_pLine = NULL;
+    delete m_pPopupMenu;
+    m_pPopupMenu = NULL;
     delete m_pMousePt;
+    m_pMousePt = NULL;
+
     MenuButton::dispose();
 }
 
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index a7a7371..21e6404 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -142,6 +142,9 @@ SwSidebarWin::~SwSidebarWin()
 
 void SwSidebarWin::dispose()
 {
+    if (IsDisposed())
+        return;
+
     mrMgr.DisconnectSidebarWinFromFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm),
                                        *this );
 
@@ -206,6 +209,7 @@ void SwSidebarWin::dispose()
 
     if (mnEventId)
         Application::RemoveUserEvent( mnEventId );
+
     vcl::Window::dispose();
 }
 
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 7502abf..20a43c0 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -4974,16 +4974,29 @@ SwEditWin::~SwEditWin()
 void SwEditWin::dispose()
 {
     m_aKeyInputTimer.Stop();
+
     delete m_pShadCrsr;
+    m_pShadCrsr = NULL;
+
     delete m_pRowColumnSelectionStart;
+    m_pRowColumnSelectionStart = NULL;
+
     if( m_pQuickHlpData->m_bIsDisplayed && m_rView.GetWrtShellPtr() )
         m_pQuickHlpData->Stop( m_rView.GetWrtShell() );
     g_bExecuteDrag = false;
     delete m_pApplyTempl;
+    m_pApplyTempl = NULL;
+
     m_rView.SetDrawFuncPtr(NULL);
 
     delete m_pUserMarker;
+    m_pUserMarker = NULL;
+
     delete m_pAnchorMarker;
+    m_pAnchorMarker = NULL;
+
+    m_aFrameControlsManager.dispose();
+
     vcl::Window::dispose();
 }
 
diff --git a/sw/source/uibase/inc/FrameControlsManager.hxx b/sw/source/uibase/inc/FrameControlsManager.hxx
index 75585ea..42584a1 100644
--- a/sw/source/uibase/inc/FrameControlsManager.hxx
+++ b/sw/source/uibase/inc/FrameControlsManager.hxx
@@ -35,7 +35,8 @@ class SwFrameControlsManager
 
     public:
         SwFrameControlsManager( SwEditWin* pEditWin );
-        ~SwFrameControlsManager( );
+        ~SwFrameControlsManager();
+        void dispose();
 
         SwFrameControlsManager( const SwFrameControlsManager& rCopy );
         const SwFrameControlsManager& operator=( const SwFrameControlsManager& rCopy );
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 101ba16..d21b70c 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -2530,6 +2530,8 @@ void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
 
 void Window::Enable( bool bEnable, bool bChild )
 {
+    if ( IsDisposed() )
+        return;
 
     if ( !bEnable )
     {
commit 7fd0cd651dbca1df4ea94b949e9e8e5b0fab1830
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Feb 27 10:09:37 2015 +0000

    dbaccess: nail the last double-dispose issue breaking the test.
    
    Change-Id: I861c970db9c36c973bcb2fa94a3e8e12f8de4f13

diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index c7ea9f3..59c5c57 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -1505,6 +1505,7 @@ void SAL_CALL ODatabaseDocument::close( sal_Bool _bDeliverOwnership ) throw (Clo
     // SYNCHRONIZED ->
     {
         DocumentGuard aGuard(*this, DocumentGuard::DefaultMethod);
+        assert (!m_bClosing);
         m_bClosing = true;
     }
     // <- SYNCHRONIZED
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
index 9f264c4..61a047e 100644
--- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
@@ -193,7 +193,6 @@ OAppDetailPageHelper::OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindo
     ,m_aBorder(new Window(this,WB_BORDER | WB_READONLY))
     ,m_aPreview(new OPreviewWindow(m_aBorder.get()))
     ,m_aDocumentInfo(new ::svtools::ODocumentInfoPreview(m_aBorder.get(), WB_LEFT | WB_VSCROLL | WB_READONLY) )
-    ,m_pTablePreview(NULL)
     ,m_ePreviewMode(_ePreviewMode)
 {
 
@@ -212,7 +211,7 @@ OAppDetailPageHelper::OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindo
 
     m_aPreview->SetHelpId(HID_APP_VIEW_PREVIEW_1);
 
-    m_pTablePreview = new OTablePreviewWindow(m_aBorder.get(), WB_READONLY | WB_DIALOGCONTROL );
+    m_pTablePreview.set( new OTablePreviewWindow(m_aBorder.get(), WB_READONLY | WB_DIALOGCONTROL ) );
     m_pTablePreview->SetHelpId(HID_APP_VIEW_PREVIEW_2);
 
     m_aDocumentInfo->SetHelpId(HID_APP_VIEW_PREVIEW_3);
@@ -259,6 +258,7 @@ void OAppDetailPageHelper::dispose()
     m_aTBPreview.disposeAndClear();
     m_aPreview.disposeAndClear();
     m_aDocumentInfo.disposeAndClear();
+    m_pTablePreview.disposeAndClear();
     m_aBorder.disposeAndClear();
     m_aMenu.reset();
 
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.hxx b/dbaccess/source/ui/app/AppDetailPageHelper.hxx
index a9272fa..90de8ea 100644
--- a/dbaccess/source/ui/app/AppDetailPageHelper.hxx
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.hxx
@@ -84,8 +84,8 @@ namespace dbaui
         VclPtr<Window>            m_aBorder;
         VclPtr<OPreviewWindow>    m_aPreview;
         VclPtr<::svtools::ODocumentInfoPreview>
-                                 m_aDocumentInfo;
-        vcl::Window*             m_pTablePreview;
+                                  m_aDocumentInfo;
+        VclPtr<vcl::Window>       m_pTablePreview;
         ::std::unique_ptr<PopupMenu> m_aMenu;
         PreviewMode         m_ePreviewMode;
         ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame2 >
diff --git a/dbaccess/source/ui/browser/dataview.cxx b/dbaccess/source/ui/browser/dataview.cxx
index ab23fb2..5e617a1 100644
--- a/dbaccess/source/ui/browser/dataview.cxx
+++ b/dbaccess/source/ui/browser/dataview.cxx
@@ -65,10 +65,9 @@ namespace dbaui
                             WinBits nStyle)
         :Window(pParent,nStyle)
         ,m_xContext(_rxContext)
-        ,m_rController( _rController )
+        ,m_xController( &_rController )
         ,m_aSeparator( new FixedLine(this) )
     {
-        m_rController.acquire();
         m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper());
         m_aSeparator->Show();
     }
@@ -84,7 +83,7 @@ namespace dbaui
 
     void ODataView::dispose()
     {
-        m_rController.release();
+        m_xController.clear();
         m_aSeparator.disposeAndClear();
         m_pAccel.reset();
         vcl::Window::dispose();
@@ -141,7 +140,7 @@ namespace dbaui
             case MouseNotifyEvent::KEYUP:
             case MouseNotifyEvent::MOUSEBUTTONDOWN:
             case MouseNotifyEvent::MOUSEBUTTONUP:
-                bHandled = m_rController.interceptUserInput( _rNEvt );
+                bHandled = m_xController->interceptUserInput( _rNEvt );
                 break;
             default:
                 break;
@@ -155,7 +154,7 @@ namespace dbaui
         if ( nType == StateChangedType::CONTROLBACKGROUND )
         {
             // Check if we need to get new images for normal/high contrast mode
-            m_rController.notifyHiContrastChanged();
+            m_xController->notifyHiContrastChanged();
         }
 
         if ( nType == StateChangedType::INITSHOW )
@@ -164,7 +163,7 @@ namespace dbaui
             // model's arguments.
             try
             {
-                Reference< XController > xController( m_rController.getXController(), UNO_SET_THROW );
+                Reference< XController > xController( m_xController->getXController(), UNO_SET_THROW );
                 Reference< XModel > xModel( xController->getModel(), UNO_QUERY );
                 if ( xModel.is() )
                 {
@@ -190,7 +189,7 @@ namespace dbaui
             (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
         {
             // Check if we need to get new images for normal/high contrast mode
-            m_rController.notifyHiContrastChanged();
+            m_xController->notifyHiContrastChanged();
         }
     }
     void ODataView::attachFrame(const Reference< XFrame >& _xFrame)
diff --git a/include/dbaccess/dataview.hxx b/include/dbaccess/dataview.hxx
index d625097..4dabda0 100644
--- a/include/dbaccess/dataview.hxx
+++ b/include/dbaccess/dataview.hxx
@@ -37,7 +37,7 @@ namespace dbaui
         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >    m_xContext;  // the service factory to work with
 
     protected:
-        IController&        m_rController;  // the controller in where we resides in
+        rtl::Reference<IController> m_xController;  // the controller in where we resides in
         VclPtr<FixedLine>   m_aSeparator;
         ::std::unique_ptr< ::svt::AcceleratorExecute> m_pAccel;
 
@@ -58,7 +58,7 @@ namespace dbaui
         virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
         virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
 
-        inline IController& getCommandController() const { return m_rController; }
+        inline IController& getCommandController() const { return *m_xController.get(); }
 
         /** will be called when the controls need to be resized.
         */
commit 5800a27b9c4bb6d3c766d4f2e3960b42cabdc6df
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Feb 26 17:10:15 2015 +0000

    dbaccess: protection against double disposes.
    
    Change-Id: I4ce2d00248b3d3d8370cc58155ea0607d4de482b

diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
index 5b8da7e..9f264c4 100644
--- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
@@ -257,9 +257,11 @@ void OAppDetailPageHelper::dispose()
     }
     m_aFL.disposeAndClear();
     m_aTBPreview.disposeAndClear();
-    m_aBorder.disposeAndClear();
     m_aPreview.disposeAndClear();
     m_aDocumentInfo.disposeAndClear();
+    m_aBorder.disposeAndClear();
+    m_aMenu.reset();
+
     vcl::Window::dispose();
 }
 
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index b50e746..37e08bb 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -1546,29 +1546,43 @@ SvTreeListBox::~SvTreeListBox()
 
 void SvTreeListBox::dispose()
 {
-
-    pImp->CallEventListeners( VCLEVENT_OBJECT_DYING );
-    delete pImp;
-    delete mpImpl->m_pLink;
-    ClearTabList();
-
-    delete pEdCtrl;
-    pEdCtrl = 0;
-    pModel->RemoveView( this );
-    if ( pModel->GetRefCount() == 0 )
+    if( pImp )
     {
-        pModel->Clear();
-        delete pModel;
-        pModel = NULL;
+        pImp->CallEventListeners( VCLEVENT_OBJECT_DYING );
+        delete pImp;
+        pImp = NULL;
     }
+    if( mpImpl )
+    {
+        delete mpImpl->m_pLink;
+        mpImpl->m_pLink = NULL;
+
+        ClearTabList();
+
+        delete pEdCtrl;
+        pEdCtrl = NULL;
+
+        if( pModel )
+        {
+            pModel->RemoveView( this );
+            if ( pModel->GetRefCount() == 0 )
+            {
+                pModel->Clear();
+                delete pModel;
+                pModel = NULL;
+            }
+        }
 
-    SvTreeListBox::RemoveBoxFromDDList_Impl( *this );
+        SvTreeListBox::RemoveBoxFromDDList_Impl( *this );
+
+        if( this == pDDSource )
+            pDDSource = 0;
+        if( this == pDDTarget )
+            pDDTarget = 0;
+        delete mpImpl;
+        mpImpl = NULL;
+    }
 
-    if( this == pDDSource )
-        pDDSource = 0;
-    if( this == pDDTarget )
-        pDDTarget = 0;
-    delete mpImpl;
     Control::dispose();
 }
 
commit abc903a5be857150b144f1439448d4f02edb0531
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Feb 26 16:50:17 2015 +0000

    vcl: more double dispose protection.
    
    Change-Id: Ib5c4ca5747cd55d7ea0f8c59b5aaa1f84c2a8fdc

diff --git a/svtools/source/contnr/ivctrl.cxx b/svtools/source/contnr/ivctrl.cxx
index d79b2a3..9c4465b 100644
--- a/svtools/source/contnr/ivctrl.cxx
+++ b/svtools/source/contnr/ivctrl.cxx
@@ -268,12 +268,12 @@ void SvtIconChoiceCtrl::SetEntryTextMode( SvxIconChoiceCtrlTextMode eMode, SvxIc
 
 sal_uLong SvtIconChoiceCtrl::GetEntryCount() const
 {
-    return _pImp->GetEntryCount();
+    return _pImp ? _pImp->GetEntryCount() : 0;
 }
 
 SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::GetEntry( sal_uLong nPos ) const
 {
-    return _pImp->GetEntry( nPos );
+    return _pImp ? _pImp->GetEntry( nPos ) : NULL;
 }
 
 void SvtIconChoiceCtrl::CreateAutoMnemonics( MnemonicGenerator& _rUsedMnemonics )
@@ -283,7 +283,7 @@ void SvtIconChoiceCtrl::CreateAutoMnemonics( MnemonicGenerator& _rUsedMnemonics
 
 SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::GetSelectedEntry( sal_uLong& rPos ) const
 {
-    return _pImp->GetFirstSelectedEntry( rPos );
+    return _pImp ? _pImp->GetFirstSelectedEntry( rPos ) : NULL;
 }
 
 void SvtIconChoiceCtrl::ClickIcon()
diff --git a/vcl/source/window/split.cxx b/vcl/source/window/split.cxx
index bd4b3fec..f678900 100644
--- a/vcl/source/window/split.cxx
+++ b/vcl/source/window/split.cxx
@@ -156,8 +156,12 @@ Splitter::~Splitter()
 
 void Splitter::dispose()
 {
-    TaskPaneList *pTList = GetSystemWindow()->GetTaskPaneList();
-    pTList->RemoveWindow( this );
+    SystemWindow *pSysWin = GetSystemWindow();
+    if(pSysWin)
+    {
+        TaskPaneList *pTList = pSysWin->GetTaskPaneList();
+        pTList->RemoveWindow(this);
+    }
     Window::dispose();
 }
 
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index 02f2417..19768d7 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -185,6 +185,8 @@ bool SystemWindow::PreNotify( NotifyEvent& rNEvt )
 
 TaskPaneList* SystemWindow::GetTaskPaneList()
 {
+    if( !mpImplData )
+        return NULL;
     if( mpImplData->mpTaskPaneList )
         return mpImplData->mpTaskPaneList ;
     else
commit f0969f0de927e4f63ef4e111a1ffaa841f2a81ea
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Feb 26 16:36:38 2015 +0000

    more double dispose protection.
    
    Change-Id: I61ecf1561393959bc9a3647d515c4c9ce5119752

diff --git a/dbaccess/source/ui/app/AppView.cxx b/dbaccess/source/ui/app/AppView.cxx
index 237fc3a..2e67c18 100644
--- a/dbaccess/source/ui/app/AppView.cxx
+++ b/dbaccess/source/ui/app/AppView.cxx
@@ -214,10 +214,17 @@ OApplicationView::~OApplicationView()
 
 void OApplicationView::dispose()
 {
-    stopComponentListening(m_xObject);
-    m_pWin->Hide();
-    boost::scoped_ptr<vcl::Window> aTemp(m_pWin);
-    m_pWin = NULL;
+    if (m_xObject.is())
+    {
+        stopComponentListening(m_xObject);
+        m_xObject.clear();
+    }
+    if (m_pWin)
+    {
+        m_pWin->Hide();
+        boost::scoped_ptr<vcl::Window> aTemp(m_pWin);
+        m_pWin = NULL;
+    }
     ODataView::dispose();
 }
 
diff --git a/dbaccess/source/ui/browser/dataview.cxx b/dbaccess/source/ui/browser/dataview.cxx
index ba8968f..ab23fb2 100644
--- a/dbaccess/source/ui/browser/dataview.cxx
+++ b/dbaccess/source/ui/browser/dataview.cxx
@@ -86,6 +86,7 @@ namespace dbaui
     {
         m_rController.release();
         m_aSeparator.disposeAndClear();
+        m_pAccel.reset();
         vcl::Window::dispose();
     }
 
diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx
index 2f9c39c..9f26c98 100644
--- a/svtools/source/contnr/imivctl1.cxx
+++ b/svtools/source/contnr/imivctl1.cxx
@@ -173,7 +173,6 @@ SvxIconChoiceCtrl_Impl::~SvxIconChoiceCtrl_Impl()
     aVerSBar.disposeAndClear();
     aHorSBar.disposeAndClear();
     aScrBarBox.disposeAndClear();
-
 }
 
 void SvxIconChoiceCtrl_Impl::Clear( bool bInCtor )
diff --git a/svtools/source/contnr/ivctrl.cxx b/svtools/source/contnr/ivctrl.cxx
index 3e8db3b..d79b2a3 100644
--- a/svtools/source/contnr/ivctrl.cxx
+++ b/svtools/source/contnr/ivctrl.cxx
@@ -216,7 +216,8 @@ void SvtIconChoiceCtrl::GetFocus()
 
 void SvtIconChoiceCtrl::LoseFocus()
 {
-    _pImp->LoseFocus();
+    if (_pImp)
+        _pImp->LoseFocus();
     Control::LoseFocus();
 }
 
commit 532dccdc02137540dcecc5b9dd48dfd72947bd48
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Feb 26 16:09:18 2015 +0000

    vclref: protect vs. double disposes.
    
    Change-Id: I86fe17ad9afba7ee1e87aaa732bebee1746c140f

diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index 96d1a66..482d3d3 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -334,9 +334,14 @@ void Ruler::dispose()
     if ( mnUpdateEvtId )
         Application::RemoveUserEvent( mnUpdateEvtId );
     delete mpSaveData;
+    mpSaveData = NULL;
     delete mpDragData;
+    mpDragData = NULL;
     if( pAccContext )
+    {
         pAccContext->release();
+        pAccContext = NULL;
+    }
     Window::dispose();
 }
 
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index b02eb03..adf08f0 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -353,11 +353,16 @@ void SvxRuler::dispose()
 
     pBindings->EnterRegistrations();
 
-    for(sal_uInt16 i = 0; i < CTRL_ITEM_COUNT  && pCtrlItem[i]; ++i)
-        delete pCtrlItem[i];
-    delete[] pCtrlItem;
+    if (pCtrlItem)
+    {
+        for(sal_uInt16 i = 0; i < CTRL_ITEM_COUNT  && pCtrlItem[i]; ++i)
+            delete pCtrlItem[i];
+        delete[] pCtrlItem;
+        pCtrlItem = NULL;
+    }
 
     pBindings->LeaveRegistrations();
+
     Ruler::dispose();
 }
 
commit 7553deec1aee40abd663c3c4d63d9629f69d6c2f
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Feb 26 16:09:06 2015 +0000

    vcl: new lifecycle test.
    
    Change-Id: I05500c136839877db5c4a215b15e24a8444d3c16

diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx
index dc6bbf2..2a46022 100644
--- a/vcl/qa/cppunit/lifecycle.cxx
+++ b/vcl/qa/cppunit/lifecycle.cxx
@@ -27,12 +27,14 @@ public:
     void testMultiDispose();
     void testIsolatedWidgets();
     void testParentedWidgets();
+    void testChildDispose();
 
     CPPUNIT_TEST_SUITE(LifecycleTest);
     CPPUNIT_TEST(testCast);
     CPPUNIT_TEST(testMultiDispose);
     CPPUNIT_TEST(testIsolatedWidgets);
     CPPUNIT_TEST(testParentedWidgets);
+    CPPUNIT_TEST(testChildDispose);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -94,6 +96,27 @@ void LifecycleTest::testParentedWidgets()
     testWidgets(xWin);
 }
 
+class DisposableChild : public vcl::Window
+{
+public:
+    DisposableChild(vcl::Window *pParent) : vcl::Window(pParent) {}
+    virtual ~DisposableChild()
+    {
+        dispose();
+    }
+};
+
+void LifecycleTest::testChildDispose()
+{
+    VclPtr<WorkWindow> xWin(new WorkWindow((vcl::Window *)NULL,
+                                                 WB_APP|WB_STDWORK));
+    CPPUNIT_ASSERT(xWin.get() != NULL);
+    VclPtr<DisposableChild> xChild(new DisposableChild(xWin.get()));
+    xWin->Show();
+    xChild->dispose();
+    xWin->dispose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(LifecycleTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit eb7f057e4b71aae711e786296d4fe95b840e7a8f
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Feb 26 16:07:39 2015 +0000

    vcl lifecycle: delete children in dispose.
    
    We can no longer rely on smart ptr members getting destroyed and
    tearing down children before parents in the new order.
    
    Change-Id: Ib22df93443d98f53543d3a8ac322e965623148d0

diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index cbc5de7..5e345f9 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -85,6 +85,9 @@ void Deck::dispose()
     // 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();
+
     maPanels.clear();
     vcl::Window::dispose();
 }
@@ -110,6 +113,8 @@ void Deck::Dispose (void)
     mpTitleBar.reset();
     mpFiller.reset();
     mpVerticalScrollBar.reset();
+    mpScrollContainer.reset();
+    mpScrollClipWindow.reset();
 }
 
 DeckTitleBar* Deck::GetTitleBar (void) const
diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx
index eff5d6e..9b450cc 100644
--- a/sfx2/source/sidebar/TabBar.cxx
+++ b/sfx2/source/sidebar/TabBar.cxx
@@ -69,6 +69,8 @@ TabBar::~TabBar()
 
 void TabBar::dispose()
 {
+    maItems.clear();
+    mpMenuButton.reset();
     vcl::Window::dispose();
 }
 
commit bf428ae41416e484714be9a623727949226a255e
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Tue Feb 17 22:03:11 2015 +0000

    vcl: add assert and improve lifecycle test.
    
    Change-Id: Ic70a890dae41b04d6dd1f19cbea419fe5a794af3

diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx
index 3492b52..dc6bbf2 100644
--- a/vcl/qa/cppunit/lifecycle.cxx
+++ b/vcl/qa/cppunit/lifecycle.cxx
@@ -90,6 +90,7 @@ void LifecycleTest::testParentedWidgets()
     VclPtr<WorkWindow> xWin(new WorkWindow((vcl::Window *)NULL,
                                                  WB_APP|WB_STDWORK));
     CPPUNIT_ASSERT(xWin.get() != NULL);
+    xWin->Show();
     testWidgets(xWin);
 }
 
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index ac250c6..101ba16 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -144,6 +144,10 @@ void Window::dispose()
     assert( !mpWindowImpl->mbInDispose && "vcl::Window - already in dispose()" );
     mpWindowImpl->mbInDispose = true;
 
+    assert( !mpWindowImpl->mpParent ||
+            !mpWindowImpl->mpParent->IsDisposed() ||
+            "vcl::Window child should have its parent disposed first" );
+
     // remove Key and Mouse events issued by Application::PostKey/MouseEvent
     Application::RemoveMouseAndKeyEvents( this );
 
commit ef5ee3247467a2bae5ae12f758a75758f58afaa4
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Tue Feb 17 19:49:27 2015 +0000

    vcl: more double-dispose protection, and survival after dispose.
    
    Change-Id: I271f9bcb85d07a28abef2d97ef3c31287878324d

diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 2bac5a8..80e22ae 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -123,8 +123,12 @@ ColorListBox::~ColorListBox()
 
 void ColorListBox::dispose()
 {
-    ImplDestroyColorEntries();
-    delete pColorList;
+    if ( pColorList )
+    {
+        ImplDestroyColorEntries();
+        delete pColorList;
+        pColorList = NULL;
+    }
     ListBox::dispose();
 }
 
@@ -953,8 +957,11 @@ FontNameBox::~FontNameBox()
 
 void FontNameBox::dispose()
 {
-    SaveMRUEntries (maFontMRUEntriesFile);
-    ImplDestroyFontList();
+    if (mpFontList)
+    {
+        SaveMRUEntries (maFontMRUEntriesFile);
+        ImplDestroyFontList();
+    }
     ComboBox::dispose();
 }
 
@@ -1017,6 +1024,7 @@ void FontNameBox::InitFontMRUEntriesFile()
 void FontNameBox::ImplDestroyFontList()
 {
     delete mpFontList;
+    mpFontList = NULL;
 }
 
 void FontNameBox::Fill( const FontList* pList )
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 55746fc..b2926fd 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -338,7 +338,10 @@ SvxStyleBox_Impl::~SvxStyleBox_Impl()
 void SvxStyleBox_Impl::dispose()
 {
     for(int i = 0; i < MAX_STYLES_ENTRIES; i++)
+    {
         delete m_pButtons[i];
+        m_pButtons[i] = NULL;
+    }
     ComboBox::dispose();
 }
 
@@ -2297,21 +2300,19 @@ void SvxStyleToolBoxControl::SetFamilyState( sal_uInt16 nIdx,
 
 IMPL_LINK_NOARG(SvxStyleToolBoxControl, VisibilityNotification)
 {
-
-    sal_uInt16 i;
-
     // Call ReBind() && UnBind() according to visibility
     SvxStyleBox_Impl* pBox = static_cast<SvxStyleBox_Impl*>( GetToolBox().GetItemWindow( GetId() ));
-    if ( pBox->IsVisible() && !isBound() )
+
+    if ( pBox && pBox->IsVisible() && !isBound() )
     {
-        for ( i=0; i<MAX_FAMILIES; i++ )
+        for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
             pBoundItems [i]->ReBind();
 
         bindListener();
     }
-    else if ( !pBox->IsVisible() && isBound() )
+    else if ( (!pBox || !pBox->IsVisible()) && isBound() )
     {
-        for ( i=0; i<MAX_FAMILIES; i++ )
+        for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ )
             pBoundItems[i]->UnBind();
         unbindListener();
     }
diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx
index 8a453d4..3492b52 100644
--- a/vcl/qa/cppunit/lifecycle.cxx
+++ b/vcl/qa/cppunit/lifecycle.cxx
@@ -73,11 +73,11 @@ void LifecycleTest::testWidgets(vcl::Window *pParent)
     // Some widgets really insist on adoption.
     if (pParent)
     {
-        { VclPtr<CheckBox>     aPtr(new CheckBox(pParent));    }
-//        { VclPtr<Edit>         aPtr(new Edit(pParent));        }
-//        { VclPtr<ComboBox>     aPtr(new ComboBox(pParent)); }
+        { VclPtr<CheckBox>     aPtr(new CheckBox(pParent));     }
+        { VclPtr<Edit>         aPtr(new Edit(pParent));         }
+        { VclPtr<ComboBox>     aPtr(new ComboBox(pParent));     }
+        { VclPtr<RadioButton>  aPtr(new RadioButton(pParent));  }
     }
-//    { VclPtr<RadioButton>  aPtr(new RadioButton(pParent));  }
 }
 
 void LifecycleTest::testIsolatedWidgets()
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 6396465..c0e5d9b 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -1267,7 +1267,7 @@ void ComboBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep )
 
 OUString ComboBox::GetMRUEntries( sal_Unicode cSep ) const
 {
-    return mpImplLB->GetMRUEntries( cSep );
+    return mpImplLB ? mpImplLB->GetMRUEntries( cSep ) : OUString();
 }
 
 void ComboBox::SetMaxMRUCount( sal_Int32 n )
@@ -1277,12 +1277,12 @@ void ComboBox::SetMaxMRUCount( sal_Int32 n )
 
 sal_Int32 ComboBox::GetMaxMRUCount() const
 {
-    return mpImplLB->GetMaxMRUCount();
+    return mpImplLB ? mpImplLB->GetMaxMRUCount() : 0;
 }
 
 sal_uInt16 ComboBox::GetDisplayLineCount() const
 {
-    return mpImplLB->GetDisplayLineCount();
+    return mpImplLB ? mpImplLB->GetDisplayLineCount() : 0;
 }
 
 void ComboBox::SetEntryData( sal_Int32 nPos, void* pNewData )
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index a3398ea..1e60f08 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -1381,7 +1381,7 @@ const Pointer& Window::GetPointer() const
 
 VCLXWindow* Window::GetWindowPeer() const
 {
-    return mpWindowImpl->mpVCLXWindow;
+    return mpWindowImpl ? mpWindowImpl->mpVCLXWindow : NULL;
 }
 
 void Window::SetPosPixel( const Point& rNewPos )
commit 8b9b9985b04b8f3b602890806ea905f8c7cb45ba
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Tue Feb 17 17:14:14 2015 +0000

    vcl: don't emit events on disposed objects & handle some method calls.
    
    Change-Id: If8940edceb379025e322553c4b011e348e2d79d4

diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index d4e4601..9b1e59d 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -94,6 +94,9 @@ bool Window::Notify( NotifyEvent& rNEvt )
 {
     bool nRet = false;
 
+    if (IsDisposed())
+        return false;
+
     // check for docking window
     // but do nothing if window is docked and locked
     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index d60d15d..a3398ea 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -1016,37 +1016,38 @@ const vcl::Window* Window::ImplGetFirstOverlapWindow() const
 
 vcl::Window* Window::ImplGetFrameWindow() const
 {
-    return mpWindowImpl->mpFrameWindow;
+    return mpWindowImpl ? mpWindowImpl->mpFrameWindow : NULL;
 }
 
 bool Window::IsDockingWindow() const
 {
-    return mpWindowImpl->mbDockWin;
+    return mpWindowImpl ? mpWindowImpl->mbDockWin : false;
 }
 
 bool Window::ImplIsFloatingWindow() const
 {
-    return mpWindowImpl->mbFloatWin;
+    return mpWindowImpl ? mpWindowImpl->mbFloatWin : false;
 }
 
 bool Window::ImplIsSplitter() const
 {
-    return mpWindowImpl->mbSplitter;
+    return mpWindowImpl ? mpWindowImpl->mbSplitter : false;
 }
 
 bool Window::ImplIsPushButton() const
 {
-    return mpWindowImpl->mbPushButton;
+    return mpWindowImpl ? mpWindowImpl->mbPushButton : false;
 }
 
 bool Window::ImplIsOverlapWindow() const
 {
-    return mpWindowImpl->mbOverlapWin;
+    return mpWindowImpl ? mpWindowImpl->mbOverlapWin : false;
 }
 
 void Window::ImplSetMouseTransparent( bool bTransparent )
 {
-    mpWindowImpl->mbMouseTransparent = bTransparent;
+    if (mpWindowImpl)
+        mpWindowImpl->mbMouseTransparent = bTransparent;
 }
 
 Point Window::ImplOutputToFrame( const Point& rPos )
@@ -1061,7 +1062,8 @@ Point Window::ImplFrameToOutput( const Point& rPos )
 
 void Window::SetCompoundControl( bool bCompound )
 {
-    mpWindowImpl->mbCompoundControl = bCompound;
+    if (mpWindowImpl)
+        mpWindowImpl->mbCompoundControl = bCompound;
 }
 
 void Window::IncrementLockCount()
@@ -1076,17 +1078,17 @@ void Window::DecrementLockCount()
 
 WinBits Window::GetStyle() const
 {
-    return mpWindowImpl->mnStyle;
+    return mpWindowImpl ? mpWindowImpl->mnStyle : 0;
 }
 
 WinBits Window::GetPrevStyle() const
 {
-    return mpWindowImpl->mnPrevStyle;
+    return mpWindowImpl ? mpWindowImpl->mnPrevStyle : 0;
 }
 
 WinBits Window::GetExtendedStyle() const
 {

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list