Kaydet (Commit) ea3fc61f authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

Fix sd toolbar manager lock underflows

Regressions from commit 45519023 ("Resolves: tdf#119997
toolbar layout unlock doesn't refresh ui"), commit c5977a89
("Resolves: tdf#96451 do magic to enable embedded chart sidebar
only for chart") and commit faed29ca ("for now show chart
sidebar").

It also adds an assert for the underflow, as nobody cared for
the underflow warnings since some years.

Change-Id: I86bb093987f084c85a7b640a846dfe0aefea9e48
Reviewed-on: https://gerrit.libreoffice.org/63204
Tested-by: Jenkins
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst a32dea33
...@@ -691,8 +691,8 @@ bool DocumentHolder::ShowUI( const uno::Reference< css::frame::XLayoutManager >& ...@@ -691,8 +691,8 @@ bool DocumentHolder::ShowUI( const uno::Reference< css::frame::XLayoutManager >&
if ( xOwnLM.is() && xDocAreaAcc.is() ) if ( xOwnLM.is() && xDocAreaAcc.is() )
{ {
// make sure that lock state of LM is correct even if an exception is thrown in between // make sure that lock state of LM is correct even if an exception is thrown in between
bool bUnlock = false; bool bUnlockContainerLM = false;
bool bLock = false; bool bLockOwnLM = false;
try try
{ {
// take over the control over the containers window // take over the control over the containers window
...@@ -706,18 +706,14 @@ bool DocumentHolder::ShowUI( const uno::Reference< css::frame::XLayoutManager >& ...@@ -706,18 +706,14 @@ bool DocumentHolder::ShowUI( const uno::Reference< css::frame::XLayoutManager >&
// this must be done after merging menus as we won't get the container menu otherwise // this must be done after merging menus as we won't get the container menu otherwise
xContainerLM->setDockingAreaAcceptor( uno::Reference < ui::XDockingAreaAcceptor >() ); xContainerLM->setDockingAreaAcceptor( uno::Reference < ui::XDockingAreaAcceptor >() );
bool bIsChart = false;
uno::Reference< lang::XServiceInfo> xServiceInfo(m_xComponent, uno::UNO_QUERY); uno::Reference< lang::XServiceInfo> xServiceInfo(m_xComponent, uno::UNO_QUERY);
if (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.chart2.ChartDocument")) if (!xServiceInfo.is() || !xServiceInfo->supportsService("com.sun.star.chart2.ChartDocument"))
bIsChart = true;
// prevent further changes at this LM
// TODO: moggi: why is this necessary?
if (!bIsChart)
{ {
xContainerLM->setVisible( false ); // prevent further changes at this LM
xContainerLM->setVisible(false);
xContainerLM->lock(); xContainerLM->lock();
bUnlockContainerLM = true;
} }
bUnlock = true;
// by unlocking the LM each layout change will now resize the containers window; pending layouts will be processed now // by unlocking the LM each layout change will now resize the containers window; pending layouts will be processed now
xOwnLM->setVisible( true ); xOwnLM->setVisible( true );
...@@ -727,7 +723,7 @@ bool DocumentHolder::ShowUI( const uno::Reference< css::frame::XLayoutManager >& ...@@ -727,7 +723,7 @@ bool DocumentHolder::ShowUI( const uno::Reference< css::frame::XLayoutManager >&
xSupp->setActiveFrame( m_xFrame ); xSupp->setActiveFrame( m_xFrame );
xOwnLM->unlock(); xOwnLM->unlock();
bLock = true; bLockOwnLM = true;
bResult = true; bResult = true;
// TODO/LATER: The following action should be done only if the window is not hidden // TODO/LATER: The following action should be done only if the window is not hidden
...@@ -746,7 +742,7 @@ bool DocumentHolder::ShowUI( const uno::Reference< css::frame::XLayoutManager >& ...@@ -746,7 +742,7 @@ bool DocumentHolder::ShowUI( const uno::Reference< css::frame::XLayoutManager >&
xSupp->setActiveFrame( nullptr ); xSupp->setActiveFrame( nullptr );
// remove control about containers window from own LM // remove control about containers window from own LM
if ( bLock ) if (bLockOwnLM)
xOwnLM->lock(); xOwnLM->lock();
xOwnLM->setVisible( false ); xOwnLM->setVisible( false );
xOwnLM->setDockingAreaAcceptor( uno::Reference< css::ui::XDockingAreaAcceptor >() ); xOwnLM->setDockingAreaAcceptor( uno::Reference< css::ui::XDockingAreaAcceptor >() );
...@@ -762,7 +758,7 @@ bool DocumentHolder::ShowUI( const uno::Reference< css::frame::XLayoutManager >& ...@@ -762,7 +758,7 @@ bool DocumentHolder::ShowUI( const uno::Reference< css::frame::XLayoutManager >&
// reestablish control of containers window // reestablish control of containers window
xContainerLM->setDockingAreaAcceptor( xDocAreaAcc ); xContainerLM->setDockingAreaAcceptor( xDocAreaAcc );
xContainerLM->setVisible( true ); xContainerLM->setVisible( true );
if ( bUnlock ) if (bUnlockContainerLM)
xContainerLM->unlock(); xContainerLM->unlock();
} }
catch( const uno::Exception& ) {} catch( const uno::Exception& ) {}
...@@ -805,8 +801,12 @@ bool DocumentHolder::HideUI( const uno::Reference< css::frame::XLayoutManager >& ...@@ -805,8 +801,12 @@ bool DocumentHolder::HideUI( const uno::Reference< css::frame::XLayoutManager >&
xMerge->removeMergedMenuBar(); xMerge->removeMergedMenuBar();
xContainerLM->setDockingAreaAcceptor( xDocAreaAcc ); xContainerLM->setDockingAreaAcceptor( xDocAreaAcc );
xContainerLM->setVisible( true ); uno::Reference< lang::XServiceInfo> xServiceInfo(m_xComponent, uno::UNO_QUERY);
xContainerLM->unlock(); if (!xServiceInfo.is() || !xServiceInfo->supportsService("com.sun.star.chart2.ChartDocument"))
{
xContainerLM->setVisible(true);
xContainerLM->unlock();
}
xContainerLM->doLayout(); xContainerLM->doLayout();
bResult = true; bResult = true;
......
...@@ -60,11 +60,13 @@ class ToolBarRules; ...@@ -60,11 +60,13 @@ class ToolBarRules;
/** Lock of the frame::XLayoutManager. /** Lock of the frame::XLayoutManager.
*/ */
struct LayouterLock class LayouterLock
{ {
Reference<frame::XLayoutManager> mxLayouter;
public:
explicit LayouterLock (const Reference<frame::XLayoutManager>& rxLayouter); explicit LayouterLock (const Reference<frame::XLayoutManager>& rxLayouter);
~LayouterLock(); ~LayouterLock();
Reference<frame::XLayoutManager> mxLayouter; bool is() const { return mxLayouter.is(); }
}; };
/** Store a list of tool bars for each of the tool bar groups. From /** Store a list of tool bars for each of the tool bar groups. From
...@@ -577,8 +579,8 @@ void ToolBarManager::Implementation::SetValid (bool bValid) ...@@ -577,8 +579,8 @@ void ToolBarManager::Implementation::SetValid (bool bValid)
aValue >>= mxLayouter; aValue >>= mxLayouter;
// tdf#119997 if mpSynchronousLayouterLock was created before mxLayouter was // tdf#119997 if mpSynchronousLayouterLock was created before mxLayouter was
// set then update it now that its available // set then update it now that its available
if (mpSynchronousLayouterLock && !mpSynchronousLayouterLock->mxLayouter) if (mpSynchronousLayouterLock && !mpSynchronousLayouterLock->is())
mpSynchronousLayouterLock->mxLayouter = mxLayouter; mpSynchronousLayouterLock.reset(new LayouterLock(mxLayouter));
} }
catch (const RuntimeException&) catch (const RuntimeException&)
{ {
......
...@@ -543,6 +543,7 @@ void SfxWorkWindow::Lock_Impl( bool bLock ) ...@@ -543,6 +543,7 @@ void SfxWorkWindow::Lock_Impl( bool bLock )
if ( m_nLock<0 ) if ( m_nLock<0 )
{ {
OSL_FAIL("Lock count underflow!"); OSL_FAIL("Lock count underflow!");
assert(m_nLock >= 0);
m_nLock = 0; m_nLock = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment