Kaydet (Commit) 61ed9eac authored tarafından Andre Fischer's avatar Andre Fischer

122095: React asynchronously to context changes to avoid problems in SFX2.

üst cee337cf
...@@ -99,6 +99,7 @@ SidebarController::SidebarController ( ...@@ -99,6 +99,7 @@ SidebarController::SidebarController (
maCurrentContext(OUString(), OUString()), maCurrentContext(OUString(), OUString()),
msCurrentDeckId(A2S("PropertyDeck")), msCurrentDeckId(A2S("PropertyDeck")),
maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)),
maContextChangeUpdate(::boost::bind(&SidebarController::UpdateConfigurations, this)),
mbIsDeckClosed(false), mbIsDeckClosed(false),
mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width()) mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width())
{ {
...@@ -175,10 +176,14 @@ void SAL_CALL SidebarController::disposing (void) ...@@ -175,10 +176,14 @@ void SAL_CALL SidebarController::disposing (void)
void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent)
throw(cssu::RuntimeException) throw(cssu::RuntimeException)
{ {
UpdateConfigurations( // Update to the requested new context asynchronously to avoid
Context( // subtle errors caused by SFX2 which in rare cases can not
// properly handle a synchronous update.
maRequestedContext = Context(
rEvent.ApplicationName, rEvent.ApplicationName,
rEvent.ContextName)); rEvent.ContextName);
if (maRequestedContext != maCurrentContext)
maContextChangeUpdate.RequestCall();
} }
...@@ -285,17 +290,17 @@ void SidebarController::NotifyResize (void) ...@@ -285,17 +290,17 @@ void SidebarController::NotifyResize (void)
void SidebarController::UpdateConfigurations (const Context& rContext) void SidebarController::UpdateConfigurations (void)
{ {
if (maCurrentContext != rContext) if (maCurrentContext != maRequestedContext)
{ {
maCurrentContext = rContext; maCurrentContext = maRequestedContext;
// Notify the tab bar about the updated set of decks. // Notify the tab bar about the updated set of decks.
ResourceManager::IdContainer aDeckIds; ResourceManager::IdContainer aDeckIds;
ResourceManager::Instance().GetMatchingDecks ( ResourceManager::Instance().GetMatchingDecks (
aDeckIds, aDeckIds,
rContext, maCurrentContext,
mxFrame); mxFrame);
mpTabBar->SetDecks(aDeckIds); mpTabBar->SetDecks(aDeckIds);
...@@ -316,13 +321,13 @@ void SidebarController::UpdateConfigurations (const Context& rContext) ...@@ -316,13 +321,13 @@ void SidebarController::UpdateConfigurations (const Context& rContext)
DeckDescriptor const* pDeckDescriptor = NULL; DeckDescriptor const* pDeckDescriptor = NULL;
if ( ! bCurrentDeckMatches) if ( ! bCurrentDeckMatches)
pDeckDescriptor = ResourceManager::Instance().GetBestMatchingDeck(rContext, mxFrame); pDeckDescriptor = ResourceManager::Instance().GetBestMatchingDeck(maCurrentContext, mxFrame);
else else
pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(msCurrentDeckId); pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(msCurrentDeckId);
if (pDeckDescriptor != NULL) if (pDeckDescriptor != NULL)
{ {
msCurrentDeckId = pDeckDescriptor->msId; msCurrentDeckId = pDeckDescriptor->msId;
SwitchToDeck(*pDeckDescriptor, rContext); SwitchToDeck(*pDeckDescriptor, maCurrentContext);
// Tell the tab bar to highlight the button associated // Tell the tab bar to highlight the button associated
// with the deck. // with the deck.
...@@ -335,7 +340,7 @@ void SidebarController::UpdateConfigurations (const Context& rContext) ...@@ -335,7 +340,7 @@ void SidebarController::UpdateConfigurations (const Context& rContext)
{ {
DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar(); DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar();
if (pTitleBar != NULL) if (pTitleBar != NULL)
pTitleBar->SetTitle(msCurrentDeckTitle+A2S(" (")+rContext.msContext+A2S(")")); pTitleBar->SetTitle(msCurrentDeckTitle+A2S(" (")+maCurrentContext.msContext+A2S(")"));
} }
#endif #endif
} }
...@@ -869,7 +874,6 @@ bool SidebarController::CanModifyChildWindowWidth (void) const ...@@ -869,7 +874,6 @@ bool SidebarController::CanModifyChildWindowWidth (void) const
SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent());
if (pSplitWindow == NULL) if (pSplitWindow == NULL)
{ {
OSL_ASSERT(pSplitWindow!=NULL);
return 0; return 0;
} }
......
...@@ -111,9 +111,11 @@ private: ...@@ -111,9 +111,11 @@ private:
::boost::scoped_ptr<TabBar> mpTabBar; ::boost::scoped_ptr<TabBar> mpTabBar;
cssu::Reference<css::frame::XFrame> mxFrame; cssu::Reference<css::frame::XFrame> mxFrame;
Context maCurrentContext; Context maCurrentContext;
Context maRequestedContext;
::rtl::OUString msCurrentDeckId; ::rtl::OUString msCurrentDeckId;
::rtl::OUString msCurrentDeckTitle; ::rtl::OUString msCurrentDeckTitle;
AsynchronousCall maPropertyChangeForwarder; AsynchronousCall maPropertyChangeForwarder;
AsynchronousCall maContextChangeUpdate;
bool mbIsDeckClosed; bool mbIsDeckClosed;
/** Before the deck is closed the sidebar width is saved into this variable, /** Before the deck is closed the sidebar width is saved into this variable,
so that it can be restored when the deck is reopended. so that it can be restored when the deck is reopended.
...@@ -122,7 +124,9 @@ private: ...@@ -122,7 +124,9 @@ private:
FocusManager maFocusManager; FocusManager maFocusManager;
DECL_LINK(WindowEventHandler, VclWindowEvent*); DECL_LINK(WindowEventHandler, VclWindowEvent*);
void UpdateConfigurations (const Context& rContext); /** Make maRequestedContext the current context.
*/
void UpdateConfigurations (void);
bool ArePanelSetsEqual ( bool ArePanelSetsEqual (
const SharedPanelContainer& rCurrentPanels, const SharedPanelContainer& rCurrentPanels,
const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels); const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels);
......
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