diff options
Diffstat (limited to 'sfx2/source/sidebar/Deck.cxx')
-rw-r--r-- | sfx2/source/sidebar/Deck.cxx | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx index 831c05325d8c..de2066defd74 100644 --- a/sfx2/source/sidebar/Deck.cxx +++ b/sfx2/source/sidebar/Deck.cxx @@ -48,11 +48,11 @@ Deck::Deck ( maIcon(), mnMinimalWidth(0), maPanels(), - mpTitleBar(new DeckTitleBar(rDeckDescriptor.msTitle, this, rCloserAction)), - mpScrollClipWindow(new vcl::Window(this)), - mpScrollContainer(new ScrollContainerWindow(mpScrollClipWindow.get())), - mpFiller(new vcl::Window(this)), - mpVerticalScrollBar(new ScrollBar(this)) + mpTitleBar(VclPtr<DeckTitleBar>::Create(rDeckDescriptor.msTitle, this, rCloserAction)), + mpScrollClipWindow(VclPtr<vcl::Window>::Create(this)), + mpScrollContainer(VclPtr<ScrollContainerWindow>::Create(mpScrollClipWindow.get())), + mpFiller(VclPtr<vcl::Window>::Create(this)), + mpVerticalScrollBar(VclPtr<ScrollBar>::Create(this)) { SetBackground(Wallpaper()); @@ -75,35 +75,27 @@ Deck::Deck ( Deck::~Deck() { - Dispose(); - - // We have to explicitly trigger the destruction of panels. - // Otherwise that is done by one of our base class destructors - // without updating maPanels. - maPanels.clear(); + disposeOnce(); } -void Deck::Dispose() +void Deck::dispose() { SharedPanelContainer aPanels; aPanels.swap(maPanels); - for (SharedPanelContainer::iterator - iPanel(aPanels.begin()), - iEnd(aPanels.end()); - iPanel!=iEnd; - ++iPanel) - { - if (*iPanel) - { - (*iPanel)->Dispose(); - OSL_ASSERT(iPanel->unique()); - iPanel->reset(); - } - } - mpTitleBar.reset(); - mpFiller.reset(); - mpVerticalScrollBar.reset(); + // We have to explicitly trigger the destruction of panels. + // Otherwise that is done by one of our base class destructors + // without updating maPanels. + for (size_t i = 0; i < aPanels.size(); i++) + aPanels[i].disposeAndClear(); + + mpTitleBar.disposeAndClear(); + mpFiller.disposeAndClear(); + mpVerticalScrollBar.disposeAndClear(); + mpScrollContainer.disposeAndClear(); + mpScrollClipWindow.disposeAndClear(); + + vcl::Window::dispose(); } DeckTitleBar* Deck::GetTitleBar() const @@ -210,8 +202,21 @@ bool Deck::ProcessWheelEvent(CommandEvent* pCommandEvent) return true; } -void Deck::SetPanels (const SharedPanelContainer& rPanels) +/** + * This container may contain existing panels that are + * being re-used, and new ones too. + */ +void Deck::ResetPanels (const SharedPanelContainer& rPanels) { + // First dispose old panels we no longer need. + for (size_t i = 0; i < maPanels.size(); i++) + { + bool bFound = false; + for (size_t j = 0; j < rPanels.size(); j++) + bFound = bFound || (maPanels[i].get() == rPanels[j].get()); + if (!bFound) // this one didn't survive. + maPanels[i].disposeAndClear(); + } maPanels = rPanels; RequestLayout(); @@ -323,10 +328,6 @@ Deck::ScrollContainerWindow::ScrollContainerWindow (vcl::Window* pParentWindow) #endif } -Deck::ScrollContainerWindow::~ScrollContainerWindow() -{ -} - void Deck::ScrollContainerWindow::Paint (const Rectangle& rUpdateArea) { (void)rUpdateArea; |