summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-04-14 11:52:19 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-04-14 13:18:05 +0100
commit6f9c00dfe02cdc62ad1b9798a0d007e1303a96e6 (patch)
tree2ccd1a746abd6a60cce4b8e7778bd725914b4fed
parentca7fa9bdad7b07955cd1783d2e58f06cb0533703 (diff)
Sidebar lifecycle - dispose panel if we fail to construct it properly.
Change-Id: I5e46e72227ac8532aed10758e1ccbb2b452ba8d4
-rw-r--r--include/sfx2/sidebar/ControlFactory.hxx5
-rw-r--r--sfx2/source/sidebar/ControlFactory.cxx8
-rw-r--r--sfx2/source/sidebar/Deck.cxx13
-rw-r--r--sfx2/source/sidebar/Panel.cxx2
-rw-r--r--sfx2/source/sidebar/SidebarChildWindow.cxx4
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx15
-rw-r--r--sfx2/source/sidebar/SidebarController.hxx2
-rw-r--r--sfx2/source/sidebar/TabBar.cxx10
-rw-r--r--sfx2/source/sidebar/TabBar.hxx2
-rw-r--r--sw/inc/AnnotationWin.hxx2
-rw-r--r--sw/inc/SidebarWin.hxx2
-rw-r--r--sw/source/uibase/docvw/AnnotationWin.cxx4
12 files changed, 38 insertions, 31 deletions
diff --git a/include/sfx2/sidebar/ControlFactory.hxx b/include/sfx2/sidebar/ControlFactory.hxx
index a078e00c20c2..142f249c4627 100644
--- a/include/sfx2/sidebar/ControlFactory.hxx
+++ b/include/sfx2/sidebar/ControlFactory.hxx
@@ -22,6 +22,7 @@
#include <sfx2/dllapi.h>
#include <sfx2/sidebar/SidebarToolBox.hxx>
#include <vcl/button.hxx>
+#include <vcl/vclptr.hxx>
#include <com/sun/star/frame/XFrame.hpp>
class ToolBox;
@@ -39,9 +40,9 @@ class SFX2_DLLPUBLIC ControlFactory
public:
/** Create the menu button for the task bar.
*/
- static CheckBox* CreateMenuButton (vcl::Window* pParentWindow);
+ static VclPtr<CheckBox> CreateMenuButton (vcl::Window* pParentWindow);
- static ImageRadioButton* CreateTabItem (vcl::Window* pParentWindow);
+ static VclPtr<ImageRadioButton> CreateTabItem (vcl::Window* pParentWindow);
};
diff --git a/sfx2/source/sidebar/ControlFactory.cxx b/sfx2/source/sidebar/ControlFactory.cxx
index 23e17a671deb..d8a49b3dd148 100644
--- a/sfx2/source/sidebar/ControlFactory.cxx
+++ b/sfx2/source/sidebar/ControlFactory.cxx
@@ -25,14 +25,14 @@
namespace sfx2 { namespace sidebar {
-CheckBox* ControlFactory::CreateMenuButton (vcl::Window* pParentWindow)
+VclPtr<CheckBox> ControlFactory::CreateMenuButton (vcl::Window* pParentWindow)
{
- return new MenuButton(pParentWindow);
+ return VclPtr<CheckBox>(new MenuButton(pParentWindow), SAL_NO_ACQUIRE);
}
-ImageRadioButton* ControlFactory::CreateTabItem (vcl::Window* pParentWindow)
+VclPtr<ImageRadioButton> ControlFactory::CreateTabItem (vcl::Window* pParentWindow)
{
- return new TabItem(pParentWindow);
+ return VclPtr<ImageRadioButton>(new TabItem(pParentWindow), SAL_NO_ACQUIRE);
}
} } // end of namespace sfx2::sidebar
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index a44217c48918..bbdac3e6bcc4 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());
@@ -88,13 +88,12 @@ void Deck::dispose()
// without updating maPanels.
for (size_t i = 0; i < aPanels.size(); i++)
aPanels[i].disposeAndClear();
- maPanels.clear();
+ mpTitleBar.disposeAndClear();
mpFiller.disposeAndClear();
mpVerticalScrollBar.disposeAndClear();
mpScrollContainer.disposeAndClear();
mpScrollClipWindow.disposeAndClear();
- mpTitleBar.disposeAndClear();
vcl::Window::dispose();
}
diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx
index 8be4f2858142..c0246e59656e 100644
--- a/sfx2/source/sidebar/Panel.cxx
+++ b/sfx2/source/sidebar/Panel.cxx
@@ -51,7 +51,7 @@ Panel::Panel (
const ::boost::function<Context(void)>& rContextAccess)
: Window(pParentWindow),
msPanelId(rPanelDescriptor.msId),
- mpTitleBar(new PanelTitleBar(
+ mpTitleBar(VclPtr<PanelTitleBar>::Create(
rPanelDescriptor.msTitle,
pParentWindow,
this)),
diff --git a/sfx2/source/sidebar/SidebarChildWindow.cxx b/sfx2/source/sidebar/SidebarChildWindow.cxx
index 05fad1caacf8..c1b50bcd372a 100644
--- a/sfx2/source/sidebar/SidebarChildWindow.cxx
+++ b/sfx2/source/sidebar/SidebarChildWindow.cxx
@@ -37,11 +37,11 @@ SidebarChildWindow::SidebarChildWindow (
SfxChildWinInfo* pInfo)
: SfxChildWindow(pParentWindow, nId)
{
- pWindow = new SidebarDockingWindow(
+ pWindow.reset(VclPtr<SidebarDockingWindow>::Create(
pBindings,
*this,
pParentWindow,
- WB_STDDOCKWIN | WB_OWNERDRAWDECORATION | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE);
+ WB_STDDOCKWIN | WB_OWNERDRAWDECORATION | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE));
eChildAlignment = SfxChildAlignment::RIGHT;
pWindow->SetHelpId(HID_SIDEBAR_WINDOW);
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index ee99a28d3ed2..d1acaaa7a7dd 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -95,7 +95,7 @@ SidebarController::SidebarController (
: SidebarControllerInterfaceBase(m_aMutex),
mpCurrentDeck(),
mpParentWindow(pParentWindow),
- mpTabBar(new TabBar(
+ mpTabBar(VclPtr<TabBar>::Create(
mpParentWindow,
rxFrame,
::boost::bind(&SidebarController::OpenThenSwitchToDeck, this, _1),
@@ -572,7 +572,7 @@ void SidebarController::SwitchToDeck (
if ( ! mpCurrentDeck)
{
mpCurrentDeck.reset(
- new Deck(
+ VclPtr<Deck>::Create(
rDeckDescriptor,
mpParentWindow,
::boost::bind(&SidebarController::RequestCloseDeck, this)));
@@ -593,6 +593,7 @@ void SidebarController::SwitchToDeck (
const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size());
SharedPanelContainer aNewPanels;
const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels());
+ // FIXME: concerns wrt. dispose / lifecycle when we re-use panels here...
aNewPanels.resize(nNewPanelCount);
sal_Int32 nWriteIndex (0);
bool bHasPanelSetChanged (false);
@@ -640,6 +641,7 @@ void SidebarController::SwitchToDeck (
mpCurrentDeck->GetPanelParentWindow(),
rPanelContexDescriptor.mbIsInitiallyVisible,
rContext);
+ aNewPanels[nWriteIndex].disposeAndClear();
bHasPanelSetChanged = true;
}
if (aNewPanels[nWriteIndex] != nullptr)
@@ -658,6 +660,7 @@ void SidebarController::SwitchToDeck (
}
}
+ // mpCurrentPanels - may miss stuff (?)
aNewPanels.resize(nWriteIndex);
// Activate the deck and the new set of panels.
@@ -683,7 +686,7 @@ void SidebarController::SwitchToDeck (
UpdateTitleBarIcons();
}
-Panel* SidebarController::CreatePanel (
+VclPtr<Panel> SidebarController::CreatePanel (
const OUString& rsPanelId,
vcl::Window* pParentWindow,
const bool bIsInitiallyExpanded,
@@ -694,7 +697,7 @@ Panel* SidebarController::CreatePanel (
return NULL;
// Create the panel which is the parent window of the UIElement.
- Panel *pPanel = new Panel(
+ VclPtr<Panel> pPanel = VclPtr<Panel>::Create(
*pPanelDescriptor,
pParentWindow,
bIsInitiallyExpanded,
@@ -714,7 +717,7 @@ Panel* SidebarController::CreatePanel (
}
else
{
- pPanel = NULL;
+ pPanel.disposeAndClear();
}
return pPanel;
@@ -1099,7 +1102,7 @@ void SidebarController::UpdateCloseIndicator (const bool bCloseAfterDrag)
// Make sure that the indicator exists.
if ( ! mpCloseIndicator)
{
- mpCloseIndicator.reset(new FixedImage(mpParentWindow));
+ mpCloseIndicator.reset(VclPtr<FixedImage>::Create(mpParentWindow));
FixedImage* pFixedImage = static_cast<FixedImage*>(mpCloseIndicator.get());
const Image aImage (Theme::GetImage(Theme::Image_CloseIndicator));
pFixedImage->SetImage(aImage);
diff --git a/sfx2/source/sidebar/SidebarController.hxx b/sfx2/source/sidebar/SidebarController.hxx
index 68f634d86b98..99941c36f4ca 100644
--- a/sfx2/source/sidebar/SidebarController.hxx
+++ b/sfx2/source/sidebar/SidebarController.hxx
@@ -198,7 +198,7 @@ private:
const ::rtl::OUString& rsImplementationURL,
const bool bWantsCanvas,
const Context& rContext);
- Panel* CreatePanel (
+ VclPtr<Panel> CreatePanel (
const ::rtl::OUString& rsPanelId,
vcl::Window* pParentWindow,
const bool bIsInitiallyExpanded,
diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx
index b055ec343f2a..20c1da235370 100644
--- a/sfx2/source/sidebar/TabBar.cxx
+++ b/sfx2/source/sidebar/TabBar.cxx
@@ -69,6 +69,11 @@ TabBar::~TabBar()
void TabBar::dispose()
{
+ for(ItemContainer::iterator
+ iItem(maItems.begin()), iEnd(maItems.end());
+ iItem!=iEnd;
+ ++iItem)
+ iItem->mpButton.disposeAndClear();
maItems.clear();
mpMenuButton.disposeAndClear();
vcl::Window::dispose();
@@ -254,12 +259,11 @@ bool TabBar::Notify (NotifyEvent&)
return false;
}
-RadioButton* TabBar::CreateTabItem (const DeckDescriptor& rDeckDescriptor)
+VclPtr<RadioButton> TabBar::CreateTabItem (const DeckDescriptor& rDeckDescriptor)
{
- RadioButton* pItem = ControlFactory::CreateTabItem(this);
+ VclPtr<RadioButton> pItem = ControlFactory::CreateTabItem(this);
pItem->SetHelpText(rDeckDescriptor.msHelpText);
pItem->SetQuickHelpText(rDeckDescriptor.msHelpText);
-
return pItem;
}
diff --git a/sfx2/source/sidebar/TabBar.hxx b/sfx2/source/sidebar/TabBar.hxx
index 31778a5d180d..a1061c3648dc 100644
--- a/sfx2/source/sidebar/TabBar.hxx
+++ b/sfx2/source/sidebar/TabBar.hxx
@@ -111,7 +111,7 @@ private:
sal_Int32 mnMenuSeparatorY;
PopupMenuProvider maPopupMenuProvider;
- RadioButton* CreateTabItem (const DeckDescriptor& rDeckDescriptor);
+ VclPtr<RadioButton> CreateTabItem (const DeckDescriptor& rDeckDescriptor);
Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const;
void Layout (void);
void UpdateButtonIcons (void);
diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 8533cfe92a1a..3f63b27aca34 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -56,7 +56,7 @@ class SwAnnotationWin : public sw::sidebarwindows::SwSidebarWin
virtual bool IsProtected() SAL_OVERRIDE;
protected:
- virtual MenuButton* CreateMenuButton() SAL_OVERRIDE;
+ virtual VclPtr<MenuButton> CreateMenuButton() SAL_OVERRIDE;
private:
virtual SvxLanguageItem GetLanguage(void) SAL_OVERRIDE;
diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
index 34957135b6b6..6d5c90d9ae2e 100644
--- a/sw/inc/SidebarWin.hxx
+++ b/sw/inc/SidebarWin.hxx
@@ -184,7 +184,7 @@ class SwSidebarWin : public vcl::Window
virtual void LoseFocus() SAL_OVERRIDE;
virtual void Paint( const Rectangle& rRect) SAL_OVERRIDE;
virtual void GetFocus() SAL_OVERRIDE;
- virtual MenuButton* CreateMenuButton() = 0;
+ virtual VclPtr<MenuButton> CreateMenuButton() = 0;
void SetSizePixel( const Size& rNewSize ) SAL_OVERRIDE;
SfxItemSet DefaultItem();
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx
index 2d253baa4976..c061708ff572 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -213,7 +213,7 @@ sal_uInt32 SwAnnotationWin::CountFollowing()
return aCount - 1;
}
-MenuButton* SwAnnotationWin::CreateMenuButton()
+VclPtr<MenuButton> SwAnnotationWin::CreateMenuButton()
{
mpButtonPopup = new PopupMenu(SW_RES(MN_ANNOTATION_BUTTON));
OUString aText = mpButtonPopup->GetItemText( FN_DELETE_NOTE_AUTHOR );
@@ -221,7 +221,7 @@ MenuButton* SwAnnotationWin::CreateMenuButton()
aRewriter.AddRule(UndoArg1,GetAuthor());
aText = aRewriter.Apply(aText);
mpButtonPopup->SetItemText(FN_DELETE_NOTE_AUTHOR,aText);
- MenuButton* pMenuButton = new AnnotationMenuButton( *this );
+ VclPtr<MenuButton> pMenuButton( new AnnotationMenuButton( *this ), SAL_NO_ACQUIRE );
pMenuButton->SetPopupMenu( mpButtonPopup );
pMenuButton->Show();
return pMenuButton;