From 3a218acef4004d8f4dc53bf904127b2a7de3f96a Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 30 Sep 2014 14:35:11 +0200 Subject: sc: lock SolarMutex before calling ScDocument::RemoveUnoObject() This can race against other threads calling AddUnoObject(), and hopefully this should fix the assert from SfxBroadcaster::AddListener() line 96 that has been observed in sc_unoapi. Change-Id: Ia2dd38a499c51a77c54cffe9dde31e14053ae0e5 --- sc/source/ui/unoobj/addruno.cxx | 2 ++ sc/source/ui/unoobj/cellsuno.cxx | 14 ++++++++++++++ sc/source/ui/unoobj/chart2uno.cxx | 6 ++++++ sc/source/ui/unoobj/chartuno.cxx | 4 ++++ sc/source/ui/unoobj/confuno.cxx | 2 ++ sc/source/ui/unoobj/dapiuno.cxx | 4 ++++ sc/source/ui/unoobj/datauno.cxx | 8 ++++++++ sc/source/ui/unoobj/defltuno.cxx | 2 ++ sc/source/ui/unoobj/docuno.cxx | 16 ++++++++++++++++ sc/source/ui/unoobj/drdefuno.cxx | 2 ++ sc/source/ui/unoobj/eventuno.cxx | 2 ++ sc/source/ui/unoobj/fielduno.cxx | 2 ++ sc/source/ui/unoobj/forbiuno.cxx | 2 ++ sc/source/ui/unoobj/linkuno.cxx | 12 ++++++++++++ sc/source/ui/unoobj/nameuno.cxx | 8 ++++++++ sc/source/ui/unoobj/notesuno.cxx | 2 ++ sc/source/ui/unoobj/styleuno.cxx | 6 ++++++ sc/source/ui/unoobj/targuno.cxx | 4 ++++ sc/source/ui/unoobj/tokenuno.cxx | 2 ++ sc/source/ui/view/tabvwshh.cxx | 2 ++ 20 files changed, 102 insertions(+) diff --git a/sc/source/ui/unoobj/addruno.cxx b/sc/source/ui/unoobj/addruno.cxx index a9dd77d18066..0c2cb0b76a01 100644 --- a/sc/source/ui/unoobj/addruno.cxx +++ b/sc/source/ui/unoobj/addruno.cxx @@ -42,6 +42,8 @@ ScAddressConversionObj::ScAddressConversionObj(ScDocShell* pDocSh, bool _bIsRang ScAddressConversionObj::~ScAddressConversionObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 0d19e29a72e1..0b7ae884b03a 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1440,6 +1440,8 @@ ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) : ScCellRangesBase::~ScCellRangesBase() { + SolarMutexGuard g; + // call RemoveUnoObject first, so no notification can happen // during ForgetCurrentAttrs @@ -8996,6 +8998,8 @@ ScCellsObj::ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR) : ScCellsObj::~ScCellsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -9093,6 +9097,8 @@ void ScCellsEnumeration::CheckPos_Impl() ScCellsEnumeration::~ScCellsEnumeration() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); delete pMark; @@ -9188,6 +9194,8 @@ ScCellFormatsObj::ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) : ScCellFormatsObj::~ScCellFormatsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -9317,6 +9325,8 @@ ScCellFormatsEnumeration::ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScR ScCellFormatsEnumeration::~ScCellFormatsEnumeration() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); delete pIter; @@ -9416,6 +9426,8 @@ ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -9672,6 +9684,8 @@ ScUniqueCellFormatsEnumeration::ScUniqueCellFormatsEnumeration(ScDocShell* pDocS ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 7ba85d176556..46d3faee3789 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -1011,6 +1011,8 @@ ScChart2DataProvider::ScChart2DataProvider( ScDocument* pDoc ) ScChart2DataProvider::~ScChart2DataProvider() { + SolarMutexGuard g; + if ( m_pDocument ) m_pDocument->RemoveUnoObject( *this); } @@ -2411,6 +2413,8 @@ ScChart2DataSource::ScChart2DataSource( ScDocument* pDoc) ScChart2DataSource::~ScChart2DataSource() { + SolarMutexGuard g; + if ( m_pDocument ) m_pDocument->RemoveUnoObject( *this); } @@ -2515,6 +2519,8 @@ ScChart2DataSequence::ScChart2DataSequence( ScDocument* pDoc, ScChart2DataSequence::~ScChart2DataSequence() { + SolarMutexGuard g; + if ( m_pDocument ) { m_pDocument->RemoveUnoObject( *this); diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index be1db435025f..c20fcfc98fb6 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -96,6 +96,8 @@ ScChartsObj::ScChartsObj(ScDocShell* pDocSh, SCTAB nT) : ScChartsObj::~ScChartsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -455,6 +457,8 @@ ScChartObj::ScChartObj(ScDocShell* pDocSh, SCTAB nT, const OUString& rN) ScChartObj::~ScChartObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx index 5891036bb6c5..636180fdf94d 100644 --- a/sc/source/ui/unoobj/confuno.cxx +++ b/sc/source/ui/unoobj/confuno.cxx @@ -89,6 +89,8 @@ ScDocumentConfiguration::ScDocumentConfiguration(ScDocShell* pDocSh) ScDocumentConfiguration::~ScDocumentConfiguration() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index 59c5c5a4956d..57d055994913 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -288,6 +288,8 @@ ScDataPilotTablesObj::ScDataPilotTablesObj(ScDocShell* pDocSh, SCTAB nT) : ScDataPilotTablesObj::~ScDataPilotTablesObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -583,6 +585,8 @@ ScDataPilotDescriptorBase::ScDataPilotDescriptorBase(ScDocShell* pDocSh) : ScDataPilotDescriptorBase::~ScDataPilotDescriptorBase() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index bcf8c77eb037..540771da77fc 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -998,6 +998,8 @@ ScFilterDescriptorBase::ScFilterDescriptorBase(ScDocShell* pDocShell) : ScFilterDescriptorBase::~ScFilterDescriptorBase() { + SolarMutexGuard g; + if (pDocSh) pDocSh->GetDocument().RemoveUnoObject(*this); } @@ -1653,6 +1655,8 @@ ScDatabaseRangeObj::ScDatabaseRangeObj(ScDocShell* pDocSh, const SCTAB nTab) : ScDatabaseRangeObj::~ScDatabaseRangeObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -2210,6 +2214,8 @@ ScDatabaseRangesObj::ScDatabaseRangesObj(ScDocShell* pDocSh) : ScDatabaseRangesObj::~ScDatabaseRangesObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -2405,6 +2411,8 @@ ScUnnamedDatabaseRangesObj::ScUnnamedDatabaseRangesObj(ScDocShell* pDocSh) : ScUnnamedDatabaseRangesObj::~ScUnnamedDatabaseRangesObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/defltuno.cxx b/sc/source/ui/unoobj/defltuno.cxx index 8c098aff5aa1..0fb8f8f9dd77 100644 --- a/sc/source/ui/unoobj/defltuno.cxx +++ b/sc/source/ui/unoobj/defltuno.cxx @@ -82,6 +82,8 @@ ScDocDefaultsObj::ScDocDefaultsObj(ScDocShell* pDocSh) : ScDocDefaultsObj::~ScDocDefaultsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index c4c5b0a71e78..de1465282db1 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -362,6 +362,8 @@ ScModelObj::ScModelObj( ScDocShell* pDocSh ) : ScModelObj::~ScModelObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); @@ -2425,6 +2427,8 @@ ScDrawPagesObj::ScDrawPagesObj(ScDocShell* pDocSh) : ScDrawPagesObj::~ScDrawPagesObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -2535,6 +2539,8 @@ ScTableSheetsObj::ScTableSheetsObj(ScDocShell* pDocSh) : ScTableSheetsObj::~ScTableSheetsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -2943,6 +2949,8 @@ ScTableColumnsObj::ScTableColumnsObj(ScDocShell* pDocSh, SCTAB nT, SCCOL nSC, SC ScTableColumnsObj::~ScTableColumnsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -3209,6 +3217,8 @@ ScTableRowsObj::ScTableRowsObj(ScDocShell* pDocSh, SCTAB nT, SCROW nSR, SCROW nE ScTableRowsObj::~ScTableRowsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -3484,6 +3494,8 @@ SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableRowsObj ) ScSpreadsheetSettingsObj::~ScSpreadsheetSettingsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -3536,6 +3548,8 @@ ScAnnotationsObj::ScAnnotationsObj(ScDocShell* pDocSh, SCTAB nT) : ScAnnotationsObj::~ScAnnotationsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -3666,6 +3680,8 @@ ScScenariosObj::ScScenariosObj(ScDocShell* pDocSh, SCTAB nT) : ScScenariosObj::~ScScenariosObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/drdefuno.cxx b/sc/source/ui/unoobj/drdefuno.cxx index d27a29320179..8aa5ca94af51 100644 --- a/sc/source/ui/unoobj/drdefuno.cxx +++ b/sc/source/ui/unoobj/drdefuno.cxx @@ -35,6 +35,8 @@ ScDrawDefaultsObj::ScDrawDefaultsObj(ScDocShell* pDocSh) : ScDrawDefaultsObj::~ScDrawDefaultsObj() throw () { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/eventuno.cxx b/sc/source/ui/unoobj/eventuno.cxx index 79e2971fd3fd..80aabff01b53 100644 --- a/sc/source/ui/unoobj/eventuno.cxx +++ b/sc/source/ui/unoobj/eventuno.cxx @@ -37,6 +37,8 @@ ScSheetEventsObj::ScSheetEventsObj(ScDocShell* pDocSh, SCTAB nT) : ScSheetEventsObj::~ScSheetEventsObj() { + SolarMutexGuard g; + if (mpDocShell) mpDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx index 4e3a4b7f7c37..36da2966796b 100644 --- a/sc/source/ui/unoobj/fielduno.cxx +++ b/sc/source/ui/unoobj/fielduno.cxx @@ -289,6 +289,8 @@ ScCellFieldsObj::ScCellFieldsObj( ScCellFieldsObj::~ScCellFieldsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); diff --git a/sc/source/ui/unoobj/forbiuno.cxx b/sc/source/ui/unoobj/forbiuno.cxx index 6f1562fd67f1..c6fe2d438d9b 100644 --- a/sc/source/ui/unoobj/forbiuno.cxx +++ b/sc/source/ui/unoobj/forbiuno.cxx @@ -53,6 +53,8 @@ ScForbiddenCharsObj::ScForbiddenCharsObj( ScDocShell* pDocSh ) : ScForbiddenCharsObj::~ScForbiddenCharsObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx index 2f895d80bb80..1bc5987038ca 100644 --- a/sc/source/ui/unoobj/linkuno.cxx +++ b/sc/source/ui/unoobj/linkuno.cxx @@ -82,6 +82,8 @@ ScSheetLinkObj::ScSheetLinkObj(ScDocShell* pDocSh, const OUString& rName) : ScSheetLinkObj::~ScSheetLinkObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -380,6 +382,8 @@ ScSheetLinksObj::ScSheetLinksObj(ScDocShell* pDocSh) : ScSheetLinksObj::~ScSheetLinksObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -607,6 +611,8 @@ ScAreaLinkObj::ScAreaLinkObj(ScDocShell* pDocSh, size_t nP) : ScAreaLinkObj::~ScAreaLinkObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -923,6 +929,8 @@ ScAreaLinksObj::ScAreaLinksObj(ScDocShell* pDocSh) : ScAreaLinksObj::~ScAreaLinksObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -1049,6 +1057,8 @@ ScDDELinkObj::ScDDELinkObj(ScDocShell* pDocSh, const OUString& rA, ScDDELinkObj::~ScDDELinkObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -1246,6 +1256,8 @@ ScDDELinksObj::ScDDELinksObj(ScDocShell* pDocSh) : ScDDELinksObj::~ScDDELinksObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx index 4989cd07a6da..8fe14eb1b237 100644 --- a/sc/source/ui/unoobj/nameuno.cxx +++ b/sc/source/ui/unoobj/nameuno.cxx @@ -92,6 +92,8 @@ ScNamedRangeObj::ScNamedRangeObj( rtl::Reference< ScNamedRangesObj > xParent, Sc ScNamedRangeObj::~ScNamedRangeObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -473,6 +475,8 @@ ScNamedRangesObj::ScNamedRangesObj(ScDocShell* pDocSh) : ScNamedRangesObj::~ScNamedRangesObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -935,6 +939,8 @@ ScLabelRangeObj::ScLabelRangeObj(ScDocShell* pDocSh, bool bCol, const ScRange& r ScLabelRangeObj::~ScLabelRangeObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -1054,6 +1060,8 @@ ScLabelRangesObj::ScLabelRangesObj(ScDocShell* pDocSh, bool bCol) : ScLabelRangesObj::~ScLabelRangesObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/notesuno.cxx b/sc/source/ui/unoobj/notesuno.cxx index fed3a83f161f..c3b8701fa6c8 100644 --- a/sc/source/ui/unoobj/notesuno.cxx +++ b/sc/source/ui/unoobj/notesuno.cxx @@ -68,6 +68,8 @@ ScAnnotationObj::ScAnnotationObj(ScDocShell* pDocSh, const ScAddress& rPos) : ScAnnotationObj::~ScAnnotationObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index b32e23f5b32b..d06f68bd1115 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -403,6 +403,8 @@ ScStyleFamiliesObj::ScStyleFamiliesObj(ScDocShell* pDocSh) : ScStyleFamiliesObj::~ScStyleFamiliesObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -618,6 +620,8 @@ ScStyleFamilyObj::ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam) : ScStyleFamilyObj::~ScStyleFamilyObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -974,6 +978,8 @@ void ScStyleObj::InitDoc( ScDocShell* pNewDocSh, const OUString& rNewName ) ScStyleObj::~ScStyleObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/targuno.cxx b/sc/source/ui/unoobj/targuno.cxx index 9ec5b0e416c2..75777fbadaaf 100644 --- a/sc/source/ui/unoobj/targuno.cxx +++ b/sc/source/ui/unoobj/targuno.cxx @@ -75,6 +75,8 @@ ScLinkTargetTypesObj::ScLinkTargetTypesObj(ScDocShell* pDocSh) : ScLinkTargetTypesObj::~ScLinkTargetTypesObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } @@ -142,6 +144,8 @@ ScLinkTargetTypeObj::ScLinkTargetTypeObj(ScDocShell* pDocSh, sal_uInt16 nT) : ScLinkTargetTypeObj::~ScLinkTargetTypeObj() { + SolarMutexGuard g; + if (pDocShell) pDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx index 47738aaf2a28..5e5d595ba359 100644 --- a/sc/source/ui/unoobj/tokenuno.cxx +++ b/sc/source/ui/unoobj/tokenuno.cxx @@ -72,6 +72,8 @@ ScFormulaParserObj::ScFormulaParserObj(ScDocShell* pDocSh) : ScFormulaParserObj::~ScFormulaParserObj() { + SolarMutexGuard g; + if (mpDocShell) mpDocShell->GetDocument().RemoveUnoObject(*this); } diff --git a/sc/source/ui/view/tabvwshh.cxx b/sc/source/ui/view/tabvwshh.cxx index 05ba436ebf8e..e427e1fae490 100644 --- a/sc/source/ui/view/tabvwshh.cxx +++ b/sc/source/ui/view/tabvwshh.cxx @@ -231,6 +231,8 @@ void ScTabViewShell::AddAccessibilityObject( SfxListener& rObject ) void ScTabViewShell::RemoveAccessibilityObject( SfxListener& rObject ) { + SolarMutexGuard g; + if (pAccessibilityBroadcaster) { rObject.EndListening( *pAccessibilityBroadcaster ); -- cgit