cid#1606759 Data race condition
Change-Id: I1357972c5ca8c6441533f15423134707efd36e33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177684 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Tested-by: Jenkins
This commit is contained in:
parent
f75b9f7e1e
commit
adfbf35c0c
3 changed files with 12 additions and 10 deletions
|
@ -31,7 +31,7 @@ class SvxShapeCollection final
|
|||
css::lang::XComponent>
|
||||
{
|
||||
private:
|
||||
std::mutex m_aMutex;
|
||||
mutable std::mutex m_aMutex;
|
||||
std::vector<css::uno::Reference<css::drawing::XShape>> maShapeContainer;
|
||||
comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> maEventListeners;
|
||||
bool bDisposed = false;
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
|
||||
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
|
||||
|
||||
void getAllShapes(std::vector<css::uno::Reference<css::drawing::XShape>>& rShapes) const;
|
||||
std::vector<css::uno::Reference<css::drawing::XShape>> getAllShapes() const;
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -871,17 +871,19 @@ void ChildrenManagerImpl::UpdateSelection()
|
|||
if (!xSelectedShape.is() && xSelectedShapeAccess.is())
|
||||
{
|
||||
sal_Int32 nCount = xSelectedShapeAccess->getCount();
|
||||
aSortedSelectedShapes.reserve(nCount);
|
||||
if (auto pSvxShape = dynamic_cast<SvxShapeCollection*>(xSelectedShapeAccess.get()))
|
||||
{
|
||||
pSvxShape->getAllShapes(aSortedSelectedShapes);
|
||||
aSortedSelectedShapes = pSvxShape->getAllShapes();
|
||||
}
|
||||
else
|
||||
{
|
||||
aSortedSelectedShapes.reserve(nCount);
|
||||
for (sal_Int32 i = 0; i < nCount; ++i)
|
||||
{
|
||||
css::uno::Reference<css::drawing::XShape> xShape(xSelectedShapeAccess->getByIndex(i), uno::UNO_QUERY);
|
||||
aSortedSelectedShapes.push_back(xShape);
|
||||
}
|
||||
}
|
||||
std::sort(aSortedSelectedShapes.begin(), aSortedSelectedShapes.end());
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,6 @@ sal_Int32 SAL_CALL SvxShapeCollection::getCount()
|
|||
return maShapeContainer.size();
|
||||
}
|
||||
|
||||
|
||||
uno::Any SAL_CALL SvxShapeCollection::getByIndex( sal_Int32 Index )
|
||||
{
|
||||
if( Index < 0 || Index >= getCount() )
|
||||
|
@ -158,6 +157,12 @@ uno::Any SAL_CALL SvxShapeCollection::getByIndex( sal_Int32 Index )
|
|||
return uno::Any( xShape );
|
||||
}
|
||||
|
||||
std::vector<css::uno::Reference<css::drawing::XShape>> SvxShapeCollection::getAllShapes() const
|
||||
{
|
||||
std::unique_lock g(m_aMutex);
|
||||
return maShapeContainer;
|
||||
}
|
||||
|
||||
// XElementAccess
|
||||
uno::Type SAL_CALL SvxShapeCollection::getElementType()
|
||||
{
|
||||
|
@ -185,11 +190,6 @@ uno::Sequence< OUString > SAL_CALL SvxShapeCollection::getSupportedServiceNames(
|
|||
return { u"com.sun.star.drawing.Shapes"_ustr, u"com.sun.star.drawing.ShapeCollection"_ustr };
|
||||
}
|
||||
|
||||
void SvxShapeCollection::getAllShapes(std::vector<css::uno::Reference<css::drawing::XShape>>& rShapes) const
|
||||
{
|
||||
rShapes = maShapeContainer;
|
||||
}
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
|
||||
com_sun_star_drawing_SvxShapeCollection_get_implementation(
|
||||
css::uno::XComponentContext *,
|
||||
|
|
Loading…
Reference in a new issue