diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-03-11 06:43:06 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-03-11 06:38:15 +0000 |
commit | e94d5233dd7939c54eb52fff456e817cecdf0a4c (patch) | |
tree | 24acd3465e88b1a2a26246272a41236edfbe9b21 /dbaccess | |
parent | fb827f2a342602f7e62dbdebb638326193315eb6 (diff) |
work on sane lifecylce for SfxFilter
all SfxFilter instances should now be hold inside of a std::shared_ptr.
This fixes a number of huge memory leaks in the test framework and
removes one huge source of memory issue in sfx2. SfxMedium contains a
pointer to the SfxFilter but does not own. Therefore it is required that
any SfxFilter belonging to a SfxMedium lives longer. However this seems
to work mostly by hoping that all SfxFilter instances are stored in a
global array. As we have seen with the tests this is not true (there are
also some cases inside of sd that seem to not follow that pattern as
well).
Change-Id: I12fd04a504cc4efc0a94967abd91c6fe2c6a8ce8
Reviewed-on: https://gerrit.libreoffice.org/23140
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/app/AppController.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/dbwizsetup.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/generalpage.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/UITools.hxx | 4 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/UITools.cxx | 4 |
5 files changed, 9 insertions, 7 deletions
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index 55aa240a9997..60fac0fc5978 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -380,7 +380,7 @@ void SAL_CALL OApplicationController::disposing() { OUString aFilter; INetURLObject aURL( m_xModel->getURL() ); - const SfxFilter* pFilter = getStandardDatabaseFilter(); + std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter(); if ( pFilter ) aFilter = pFilter->GetFilterName(); @@ -1126,7 +1126,7 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa 0, getView()); aFileDlg.SetDisplayDirectory( sUrl ); - const SfxFilter* pFilter = getStandardDatabaseFilter(); + std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter(); if ( pFilter ) { aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension()); diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 776fc9505a36..81e6e0660a87 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -796,7 +796,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() ::sfx2::FileDialogHelper aFileDlg( ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, 0, this); - const SfxFilter* pFilter = getStandardDatabaseFilter(); + std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter(); if ( pFilter ) { INetURLObject aWorkURL( m_sWorkPath ); diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx index 839fbff56855..bbf185e98395 100644 --- a/dbaccess/source/ui/dlg/generalpage.cxx +++ b/dbaccess/source/ui/dlg/generalpage.cxx @@ -719,7 +719,7 @@ namespace dbaui ::sfx2::FileDialogHelper aFileDlg( ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, 0, OUString("sdatabase") ); - const SfxFilter* pFilter = getStandardDatabaseFilter(); + std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter(); if ( pFilter ) { aFileDlg.SetCurrentFilter(pFilter->GetUIName()); diff --git a/dbaccess/source/ui/inc/UITools.hxx b/dbaccess/source/ui/inc/UITools.hxx index b9a45cf42620..7964c794ac93 100644 --- a/dbaccess/source/ui/inc/UITools.hxx +++ b/dbaccess/source/ui/inc/UITools.hxx @@ -26,6 +26,8 @@ #include <vcl/taskpanelist.hxx> #include <connectivity/dbtools.hxx> +#include <memory> + #define RET_ALL 10 // we only need forward decl here @@ -366,7 +368,7 @@ namespace dbaui @retrun the filter */ - const SfxFilter* getStandardDatabaseFilter(); + std::shared_ptr<const SfxFilter> getStandardDatabaseFilter(); /** opens a save dialog to store a form or report folder in the current hierarchy. @param _pParent diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 42353aa3de1a..fecce2bf7fb7 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -899,9 +899,9 @@ bool callColumnFormatDialog(vcl::Window* _pParent, return bRet; } -const SfxFilter* getStandardDatabaseFilter() +std::shared_ptr<const SfxFilter> getStandardDatabaseFilter() { - const SfxFilter* pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)"); + std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)"); OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!"); return pFilter; } |