summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dbaccess/source/ui/control/curledit.cxx5
-rw-r--r--extensions/source/propctrlr/standardcontrol.cxx13
-rw-r--r--extensions/source/propctrlr/standardcontrol.hxx2
-rw-r--r--include/svtools/svmedit.hxx2
-rw-r--r--include/vcl/combobox.hxx13
-rw-r--r--include/vcl/edit.hxx13
-rw-r--r--include/vcl/vclmedit.hxx2
-rw-r--r--include/vcl/vclref.hxx1
-rw-r--r--sd/source/ui/animations/CustomAnimationDialog.cxx45
-rw-r--r--vcl/qa/cppunit/lifecycle.cxx19
-rw-r--r--vcl/source/control/combobox.cxx11
-rw-r--r--vcl/source/control/edit.cxx87
-rw-r--r--vcl/source/window/mouse.cxx2
-rw-r--r--vcl/source/window/window2.cxx2
14 files changed, 121 insertions, 96 deletions
diff --git a/dbaccess/source/ui/control/curledit.cxx b/dbaccess/source/ui/control/curledit.cxx
index 4dc9d7fffb52..0c967bd34ef3 100644
--- a/dbaccess/source/ui/control/curledit.cxx
+++ b/dbaccess/source/ui/control/curledit.cxx
@@ -40,10 +40,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeConnectionURLEdit(vcl:
OConnectionURLEdit::~OConnectionURLEdit()
{
- // delete my sub controls
- Edit* pSubEdit = GetSubEdit();
SetSubEdit(NULL);
- delete pSubEdit;
delete m_pForcedPrefix;
}
@@ -86,7 +83,7 @@ void OConnectionURLEdit::SetText(const OUString& _rStr, const Selection& /*_rNew
{
// create new sub controls, if necessary
if (!GetSubEdit())
- SetSubEdit(new Edit(this, 0));
+ SetSubEdit(EditRef(new Edit(this, 0)));
if ( !m_pForcedPrefix )
{
m_pForcedPrefix = new FixedText(this, WB_VCENTER);
diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx
index af4d001dc784..0592b06a5955 100644
--- a/extensions/source/propctrlr/standardcontrol.cxx
+++ b/extensions/source/propctrlr/standardcontrol.cxx
@@ -1023,15 +1023,14 @@ namespace pcr
DropDownEditControl::DropDownEditControl( vcl::Window* _pParent, WinBits _nStyle )
:DropDownEditControl_Base( _pParent, _nStyle )
,m_pFloatingEdit( NULL )
- ,m_pImplEdit( NULL )
,m_pDropdownButton( NULL )
,m_nOperationMode( eStringList )
,m_bDropdown( false )
{
SetCompoundControl( true );
- m_pImplEdit = new MultiLineEdit( this, WB_TABSTOP | WB_IGNORETAB | WB_NOBORDER | (_nStyle & WB_READONLY) );
- SetSubEdit( m_pImplEdit );
+ m_pImplEdit = MultiLineEditRef( new MultiLineEdit( this, WB_TABSTOP | WB_IGNORETAB | WB_NOBORDER | (_nStyle & WB_READONLY) ) );
+ SetSubEdit( m_pImplEdit.get() );
m_pImplEdit->Show();
if ( _nStyle & WB_DROPDOWN )
@@ -1065,11 +1064,7 @@ namespace pcr
boost::scoped_ptr<vcl::Window> aTemp(m_pFloatingEdit);
m_pFloatingEdit = NULL;
}
- {
- boost::scoped_ptr<vcl::Window> aTemp(m_pImplEdit);
- SetSubEdit( NULL );
- m_pImplEdit = NULL;
- }
+ SetSubEdit(EditRef());
{
boost::scoped_ptr<vcl::Window> aTemp(m_pDropdownButton);
m_pDropdownButton = NULL;
@@ -1106,7 +1101,7 @@ namespace pcr
{
if ( m_pHelper )
{
- m_pHelper->LoseFocusHdl( m_pImplEdit );
+ m_pHelper->LoseFocusHdl( m_pImplEdit.get() );
m_pHelper->activateNextControl();
}
}
diff --git a/extensions/source/propctrlr/standardcontrol.hxx b/extensions/source/propctrlr/standardcontrol.hxx
index 8c80714bc3d5..8b125633ee2d 100644
--- a/extensions/source/propctrlr/standardcontrol.hxx
+++ b/extensions/source/propctrlr/standardcontrol.hxx
@@ -375,7 +375,7 @@ namespace pcr
{
private:
OMultilineFloatingEdit* m_pFloatingEdit;
- MultiLineEdit* m_pImplEdit;
+ VclReference<MultiLineEdit> m_pImplEdit;
PushButton* m_pDropdownButton;
MultiLineOperationMode m_nOperationMode;
bool m_bDropdown : 1;
diff --git a/include/svtools/svmedit.hxx b/include/svtools/svmedit.hxx
index 33c2b90fe6f2..726980fa77d4 100644
--- a/include/svtools/svmedit.hxx
+++ b/include/svtools/svmedit.hxx
@@ -27,7 +27,6 @@
#include <svtools/colorcfg.hxx>
-
class SVT_DLLPUBLIC MultiLineEdit : public VclMultiLineEdit
{
public:
@@ -36,6 +35,7 @@ public:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
GetComponentInterface(bool bCreate = true) SAL_OVERRIDE;
};
+typedef VclReference<MultiLineEdit> MultiLineEditRef;
#endif // INCLUDED_SVTOOLS_SVMEDIT_HXX
diff --git a/include/vcl/combobox.hxx b/include/vcl/combobox.hxx
index c7a8cef99851..cde4846bdb2f 100644
--- a/include/vcl/combobox.hxx
+++ b/include/vcl/combobox.hxx
@@ -39,7 +39,7 @@ class ImplBtn;
class VCL_DLLPUBLIC ComboBox : public Edit
{
private:
- Edit* mpSubEdit;
+ VclReference<Edit> mpSubEdit;
ImplListBox* mpImplLB;
ImplBtn* mpBtn;
ImplListBoxFloatingWindow* mpFloatWin;
@@ -48,7 +48,7 @@ private:
bool mbDDAutoSize : 1;
bool mbSyntheticModify : 1;
bool mbMatchCase : 1;
- sal_Int32 m_nMaxWidthChars;
+ sal_Int32 m_nMaxWidthChars;
Link maSelectHdl;
Link maDoubleClickHdl;
boost::signals2::scoped_connection mAutocompleteConnection;
@@ -73,7 +73,7 @@ private:
DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl, void* );
DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl, void* );
DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl, void* );
- DECL_DLLPRIVATE_LINK( ImplListItemSelectHdl , void* );
+ DECL_DLLPRIVATE_LINK( ImplListItemSelectHdl , void* );
SAL_DLLPRIVATE void ImplClickButtonHandler( ImplBtn* );
SAL_DLLPRIVATE void ImplUserDrawHandler( UserDrawEvent* );
@@ -90,7 +90,7 @@ protected:
protected:
bool IsDropDownBox() const { return mpFloatWin ? true : false; }
- virtual void FillLayoutData() const SAL_OVERRIDE;
+ virtual void FillLayoutData() const SAL_OVERRIDE;
public:
explicit ComboBox( vcl::Window* pParent, WinBits nStyle = 0 );
explicit ComboBox( vcl::Window* pParent, const ResId& );
@@ -119,12 +119,12 @@ public:
Rectangle GetDropDownPosSizePixel() const;
- void AdaptDropDownLineCountToMaximum();
+ void AdaptDropDownLineCountToMaximum();
void SetDropDownLineCount( sal_uInt16 nLines );
sal_uInt16 GetDropDownLineCount() const;
void EnableAutoSize( bool bAuto );
- bool IsAutoSizeEnabled() const { return mbDDAutoSize; }
+ bool IsAutoSizeEnabled() const { return mbDDAutoSize; }
void EnableDDAutoWidth( bool b );
@@ -225,6 +225,7 @@ public:
virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
};
+typedef VclReference<ComboBox> ComboBoxPtr;
#endif // _COMBOBOX_HXX
diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx
index ec05923011b8..5a28ecb58360 100644
--- a/include/vcl/edit.hxx
+++ b/include/vcl/edit.hxx
@@ -28,6 +28,7 @@
#include <vcl/ctrl.hxx>
#include <vcl/menu.hxx>
#include <vcl/dndhelp.hxx>
+#include <vcl/vclref.hxx>
#include <com/sun/star/uno/Reference.h>
namespace com {
@@ -68,7 +69,7 @@ enum AutocompleteAction{ AUTOCOMPLETE_KEYINPUT, AUTOCOMPLETE_TABFORWARD, AUTOCOM
class VCL_DLLPUBLIC Edit : public Control, public vcl::unohelper::DragAndDropClient
{
private:
- Edit* mpSubEdit;
+ VclReference<Edit> mpSubEdit;
Timer* mpUpdateDataTimer;
TextFilter* mpFilterText;
DDInfo* mpDDInfo;
@@ -85,7 +86,7 @@ private:
sal_Int32 mnMaxWidthChars;
AutocompleteAction meAutocompleteAction;
sal_Unicode mcEchoChar;
- bool mbModified:1,
+ bool mbModified:1,
mbInternModified:1,
mbReadOnly:1,
mbInsertMode:1,
@@ -164,6 +165,7 @@ public:
Edit( vcl::Window* pParent, WinBits nStyle = WB_BORDER );
Edit( vcl::Window* pParent, const ResId& rResId );
virtual ~Edit();
+ virtual void dispose() SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
@@ -186,7 +188,7 @@ public:
virtual void SetModifyFlag();
virtual void ClearModifyFlag();
- virtual bool IsModified() const { return mpSubEdit ? mpSubEdit->mbModified : mbModified; }
+ virtual bool IsModified() const { return mpSubEdit.get() ? mpSubEdit->mbModified : mbModified; }
virtual void EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT );
virtual void DisableUpdateData() { delete mpUpdateDataTimer; mpUpdateDataTimer = NULL; }
@@ -235,8 +237,8 @@ public:
virtual const Link& GetModifyHdl() const { return maModifyHdl; }
virtual void SetUpdateDataHdl( const Link& rLink ) { maUpdateDataHdl = rLink; }
- void SetSubEdit( Edit* pEdit );
- Edit* GetSubEdit() const { return mpSubEdit; }
+ void SetSubEdit( VclReference<Edit> pEdit );
+ Edit* GetSubEdit() const { return mpSubEdit.get(); }
boost::signals2::signal< void ( Edit* ) > autocompleteSignal;
AutocompleteAction GetAutocompleteAction() const { return meAutocompleteAction; }
@@ -268,6 +270,7 @@ public:
// global style settings (needed by sc's inputwin.cxx)
static Size GetMinimumEditSize();
};
+typedef VclReference<Edit> EditRef;
#endif // INCLUDED_VCL_EDIT_HXX
diff --git a/include/vcl/vclmedit.hxx b/include/vcl/vclmedit.hxx
index 649725b1c1f2..382059b9a420 100644
--- a/include/vcl/vclmedit.hxx
+++ b/include/vcl/vclmedit.hxx
@@ -25,7 +25,6 @@
#include <vcl/edit.hxx>
#include <vcl/dllapi.h>
-
class ImpVclMEdit;
class Timer;
class ExtTextEngine;
@@ -131,6 +130,7 @@ public:
virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
};
+typedef VclReference<VclMultiLineEdit> VclMultiLineEditRef;
#endif // INCLUDED_VCL_VCLMEDIT_HXX
diff --git a/include/vcl/vclref.hxx b/include/vcl/vclref.hxx
index b9b7b530d522..ba3fdaa70719 100644
--- a/include/vcl/vclref.hxx
+++ b/include/vcl/vclref.hxx
@@ -75,7 +75,6 @@ public:
// hold it alive for the lifetime of this method
::rtl::Reference<reference_type> aTmp(m_rInnerRef);
m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-)
- assert(aTmp.get());
if (aTmp.get())
aTmp->dispose();
}
diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx
index 7ad5e3f30c03..6497b0e83c21 100644
--- a/sd/source/ui/animations/CustomAnimationDialog.cxx
+++ b/sd/source/ui/animations/CustomAnimationDialog.cxx
@@ -320,7 +320,7 @@ Control* FontPropertyBox::getControl()
class DropdownMenuBox : public Edit
{
public:
- DropdownMenuBox( vcl::Window* pParent, Edit* pSubControl, PopupMenu* pMenu );
+ DropdownMenuBox( vcl::Window* pParent, const EditRef &pSubControl, PopupMenu* pMenu );
virtual ~DropdownMenuBox();
void Resize() SAL_OVERRIDE;
@@ -329,12 +329,12 @@ public:
void SetMenuSelectHdl( const Link& rLink ) { mpDropdownButton->SetSelectHdl( rLink ); }
private:
- Edit* mpSubControl;
+ EditRef mpSubControl;
MenuButton* mpDropdownButton;
- PopupMenu* mpMenu;
+ PopupMenu* mpMenu;
};
-DropdownMenuBox::DropdownMenuBox( vcl::Window* pParent, Edit* pSubControl, PopupMenu* pMenu )
+DropdownMenuBox::DropdownMenuBox( vcl::Window* pParent, const EditRef &pSubControl, PopupMenu* pMenu )
: Edit( pParent, WB_BORDER|WB_TABSTOP| WB_DIALOGCONTROL ),
mpSubControl(pSubControl),mpDropdownButton(0),mpMenu(pMenu)
{
@@ -350,8 +350,7 @@ DropdownMenuBox::DropdownMenuBox( vcl::Window* pParent, Edit* pSubControl, Popup
DropdownMenuBox::~DropdownMenuBox()
{
- SetSubEdit( 0 );
- delete mpSubControl;
+ SetSubEdit(EditRef());
delete mpDropdownButton;
delete mpMenu;
}
@@ -407,7 +406,7 @@ public:
private:
DropdownMenuBox* mpControl;
PopupMenu* mpMenu;
- MetricField* mpMetric;
+ VclReference<MetricField> mpMetric;
};
CharHeightPropertyBox::CharHeightPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link& rModifyHdl )
@@ -419,7 +418,7 @@ CharHeightPropertyBox::CharHeightPropertyBox( sal_Int32 nControlType, vcl::Windo
mpMetric->SetMax( 1000 );
mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSIZE_POPUP ) );
- mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
+ mpControl = new DropdownMenuBox( pParent, mpMetric.get(), mpMenu );
mpControl->SetMenuSelectHdl( LINK( this, CharHeightPropertyBox, implMenuSelectHdl ));
mpControl->SetModifyHdl( rModifyHdl );
mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_CHARHEIGHTPROPERTYBOX );
@@ -450,7 +449,7 @@ IMPL_LINK( CharHeightPropertyBox, implMenuSelectHdl, MenuButton*, pPb )
void CharHeightPropertyBox::setValue( const Any& rValue, const OUString& )
{
- if( mpMetric )
+ if( mpMetric.get() )
{
double fValue = 0.0;
rValue >>= fValue;
@@ -487,7 +486,7 @@ public:
private:
DropdownMenuBox* mpControl;
PopupMenu* mpMenu;
- MetricField* mpMetric;
+ VclReference<MetricField> mpMetric;
Link maModifyHdl;
};
@@ -508,7 +507,7 @@ TransparencyPropertyBox::TransparencyPropertyBox( sal_Int32 nControlType, vcl::W
mpMenu->InsertItem( i, aStr );
}
- mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
+ mpControl = new DropdownMenuBox( pParent, mpMetric.get(), mpMenu );
mpControl->SetMenuSelectHdl( LINK( this, TransparencyPropertyBox, implMenuSelectHdl ));
mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_TRANSPARENCYPROPERTYBOX );
@@ -534,7 +533,7 @@ void TransparencyPropertyBox::updateMenu()
IMPL_LINK_NOARG(TransparencyPropertyBox, implModifyHdl)
{
updateMenu();
- maModifyHdl.Call(mpMetric);
+ maModifyHdl.Call(mpMetric.get());
return 0;
}
@@ -552,7 +551,7 @@ IMPL_LINK( TransparencyPropertyBox, implMenuSelectHdl, MenuButton*, pPb )
void TransparencyPropertyBox::setValue( const Any& rValue, const OUString& )
{
- if( mpMetric )
+ if( mpMetric.get() )
{
double fValue = 0.0;
rValue >>= fValue;
@@ -591,7 +590,7 @@ public:
private:
DropdownMenuBox* mpControl;
PopupMenu* mpMenu;
- MetricField* mpMetric;
+ VclReference<MetricField> mpMetric;
Link maModifyHdl;
};
@@ -606,7 +605,7 @@ RotationPropertyBox::RotationPropertyBox( sal_Int32 nControlType, vcl::Window* p
mpMetric->SetMax( 10000 );
mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_ROTATION_POPUP ) );
- mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
+ mpControl = new DropdownMenuBox( pParent, mpMetric.get(), mpMenu );
mpControl->SetMenuSelectHdl( LINK( this, RotationPropertyBox, implMenuSelectHdl ));
mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_ROTATIONPROPERTYBOX );
@@ -640,7 +639,7 @@ void RotationPropertyBox::updateMenu()
IMPL_LINK_NOARG(RotationPropertyBox, implModifyHdl)
{
updateMenu();
- maModifyHdl.Call(mpMetric);
+ maModifyHdl.Call(mpMetric.get());
return 0;
}
@@ -677,7 +676,7 @@ IMPL_LINK( RotationPropertyBox, implMenuSelectHdl, MenuButton*, pPb )
void RotationPropertyBox::setValue( const Any& rValue, const OUString& )
{
- if( mpMetric )
+ if( mpMetric.get() )
{
double fValue = 0.0;
rValue >>= fValue;
@@ -716,7 +715,7 @@ public:
private:
DropdownMenuBox* mpControl;
PopupMenu* mpMenu;
- MetricField* mpMetric;
+ VclReference<MetricField> mpMetric;
Link maModifyHdl;
int mnDirection;
};
@@ -731,7 +730,7 @@ ScalePropertyBox::ScalePropertyBox( sal_Int32 nControlType, vcl::Window* pParent
mpMetric->SetMax( 10000 );
mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_SCALE_POPUP ) );
- mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu );
+ mpControl = new DropdownMenuBox( pParent, mpMetric.get(), mpMenu );
mpControl->SetMenuSelectHdl( LINK( this, ScalePropertyBox, implMenuSelectHdl ));
mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_SCALEPROPERTYBOX );
@@ -764,7 +763,7 @@ void ScalePropertyBox::updateMenu()
IMPL_LINK_NOARG(ScalePropertyBox, implModifyHdl)
{
updateMenu();
- maModifyHdl.Call(mpMetric);
+ maModifyHdl.Call(mpMetric.get());
return 0;
}
@@ -810,7 +809,7 @@ IMPL_LINK( ScalePropertyBox, implMenuSelectHdl, MenuButton*, pPb )
void ScalePropertyBox::setValue( const Any& rValue, const OUString& )
{
- if( mpMetric )
+ if( mpMetric.get() )
{
ValuePair aValues;
rValue >>= aValues;
@@ -878,7 +877,7 @@ public:
private:
DropdownMenuBox* mpControl;
PopupMenu* mpMenu;
- Edit* mpEdit;
+ EditRef mpEdit;
Link maModifyHdl;
float mfFontWeight;
@@ -950,7 +949,7 @@ IMPL_LINK( FontStylePropertyBox, implMenuSelectHdl, MenuButton*, pPb )
}
update();
- maModifyHdl.Call(mpEdit);
+ maModifyHdl.Call(mpEdit.get());
return 0;
}
diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx
index 1c887b9df00d..e054672aadee 100644
--- a/vcl/qa/cppunit/lifecycle.cxx
+++ b/vcl/qa/cppunit/lifecycle.cxx
@@ -12,6 +12,9 @@
#include <vcl/wrkwin.hxx>
#include <vcl/button.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/field.hxx>
class LifecycleTest : public test::BootstrapFixture
{
@@ -20,6 +23,7 @@ class LifecycleTest : public test::BootstrapFixture
public:
LifecycleTest() : BootstrapFixture(true, false) {}
+ void testCast();
void testMultiDispose();
void testIsolatedWidgets();
void testParentedWidgets();
@@ -31,6 +35,17 @@ public:
CPPUNIT_TEST_SUITE_END();
};
+// A compile time sanity check
+void LifecycleTest::testCast()
+{
+// VclReference<PushButton> xButton(new PushButton(NULL, 0));
+// VclReference<vcl::Window> xWindow(xButton);
+
+// VclReference<MetricField> xField(new MetricField(NULL, 0));
+// VclReference<SpinField> xSpin(xField);
+// VclReference<Edit> xEdit(xField);
+}
+
void LifecycleTest::testMultiDispose()
{
VclReference<WorkWindow> xWin(new WorkWindow((vcl::Window *)NULL,
@@ -54,7 +69,9 @@ void LifecycleTest::testWidgets(vcl::Window *pParent)
// Some widgets really insist on adoption.
if (pParent)
{
- { CheckBoxPtr aPtr(new CheckBox(pParent)); }
+ { CheckBoxPtr aPtr(new CheckBox(pParent)); }
+// { EditRef aPtr(new Edit(pParent)); }
+// { ComboBoxPtr aPtr(new ComboBox(pParent)); }
}
// { RadioButtonPtr aPtr(new RadioButton(pParent)); }
}
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 8a2e3c294eb1..d7e2341f922c 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -68,8 +68,7 @@ ComboBox::ComboBox( vcl::Window* pParent, const ResId& rResId ) :
ComboBox::~ComboBox()
{
- SetSubEdit( NULL );
- delete mpSubEdit;
+ SetSubEdit(VclReference<Edit>());
ImplListBox *pImplLB = mpImplLB;
mpImplLB = NULL;
@@ -579,7 +578,7 @@ void ComboBox::Resize()
void ComboBox::FillLayoutData() const
{
mpControlData->mpLayoutData = new vcl::ControlLayoutData();
- AppendLayoutData( *mpSubEdit );
+ AppendLayoutData( *mpSubEdit.get() );
mpSubEdit->SetLayoutDataParent( this );
ImplListBoxWindowPtr rMainWindow = mpImplLB->GetMainWindow();
if( mpFloatWin )
@@ -693,7 +692,7 @@ bool ComboBox::PreNotify( NotifyEvent& rNEvt )
bool ComboBox::Notify( NotifyEvent& rNEvt )
{
bool nDone = false;
- if( ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) && ( rNEvt.GetWindow() == mpSubEdit )
+ if( ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) && ( rNEvt.GetWindow() == mpSubEdit.get() )
&& !IsReadOnly() )
{
KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
@@ -731,7 +730,7 @@ bool ComboBox::Notify( NotifyEvent& rNEvt )
case KEY_RETURN:
{
- if( ( rNEvt.GetWindow() == mpSubEdit ) && IsInDropDown() )
+ if( ( rNEvt.GetWindow() == mpSubEdit.get() ) && IsInDropDown() )
{
mpImplLB->ProcessKeyInput( aKeyEvt );
nDone = true;
@@ -749,7 +748,7 @@ bool ComboBox::Notify( NotifyEvent& rNEvt )
}
else if( (rNEvt.GetType() == MouseNotifyEvent::COMMAND) &&
(rNEvt.GetCommandEvent()->GetCommand() == COMMAND_WHEEL) &&
- (rNEvt.GetWindow() == mpSubEdit) )
+ (rNEvt.GetWindow() == mpSubEdit.get()) )
{
sal_uInt16 nWheelBehavior( GetSettings().GetMouseSettings().GetWheelBehavior() );
if ( ( nWheelBehavior == MOUSE_WHEEL_ALWAYS )
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index a35327a306d2..fa2f7b008267 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -239,7 +239,14 @@ bool Edit::set_property(const OString &rKey, const OString &rValue)
Edit::~Edit()
{
+ dispose();
+}
+
+void Edit::dispose()
+{
delete mpDDInfo;
+ mpDDInfo = NULL;
+
vcl::Cursor* pCursor = GetCursor();
if ( pCursor )
{
@@ -248,8 +255,10 @@ Edit::~Edit()
}
delete mpIMEInfos;
+ mpIMEInfos = NULL;
delete mpUpdateDataTimer;
+ mpUpdateDataTimer = NULL;
if ( mxDnDListener.is() )
{
@@ -266,6 +275,7 @@ Edit::~Edit()
uno::Reference< lang::XEventListener> xEL( mxDnDListener, uno::UNO_QUERY );
xEL->disposing( lang::EventObject() ); // #95154# #96585# Empty Source means it's the Client
+ mxDnDListener.clear();
}
SetType(WINDOW_WINDOW);
@@ -273,7 +283,7 @@ Edit::~Edit()
void Edit::ImplInitEditData()
{
- mpSubEdit = NULL;
+ mpSubEdit = EditRef();
mpUpdateDataTimer = NULL;
mpFilterText = NULL;
mnXOffset = 0;
@@ -1316,7 +1326,7 @@ void Edit::ImplPaste( uno::Reference< datatransfer::clipboard::XClipboard >& rxC
void Edit::MouseButtonDown( const MouseEvent& rMEvt )
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
{
Control::MouseButtonDown( rMEvt );
return;
@@ -1738,7 +1748,7 @@ void Edit::KeyInput( const KeyEvent& rKEvt )
if ( mpUpdateDataTimer && !mbIsSubEdit && mpUpdateDataTimer->IsActive() )
mpUpdateDataTimer->Start();//do not update while the user is still travelling in the control
- if ( mpSubEdit || !ImplHandleKeyEvent( rKEvt ) )
+ if ( mpSubEdit.get() || !ImplHandleKeyEvent( rKEvt ) )
Control::KeyInput( rKEvt );
}
@@ -1750,13 +1760,13 @@ void Edit::FillLayoutData() const
void Edit::Paint( const Rectangle& )
{
- if ( !mpSubEdit )
+ if ( !mpSubEdit.get() )
ImplRepaint();
}
void Edit::Resize()
{
- if ( !mpSubEdit && IsReallyVisible() )
+ if ( !mpSubEdit.get() && IsReallyVisible() )
{
Control::Resize();
// Wegen vertikaler Zentrierung...
@@ -1869,7 +1879,7 @@ void Edit::ImplInvalidateOutermostBorder( vcl::Window* pWin )
void Edit::GetFocus()
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->ImplGrabFocus( GetGetFocusFlags() );
else if ( !mbActivePopup )
{
@@ -1922,7 +1932,7 @@ void Edit::GetFocus()
vcl::Window* Edit::GetPreferredKeyInputWindow()
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
return mpSubEdit->GetPreferredKeyInputWindow();
else
return this;
@@ -1937,7 +1947,7 @@ void Edit::LoseFocus()
mpUpdateDataTimer->Timeout();
}
- if ( !mpSubEdit )
+ if ( !mpSubEdit.get() )
{
// FIXME: this is currently only on OS X
// check for other platforms that need similar handling
@@ -2196,11 +2206,11 @@ void Edit::StateChanged( StateChangedType nType )
{
if ( nType == StateChangedType::INITSHOW )
{
- if ( !mpSubEdit )
+ if ( !mpSubEdit.get() )
{
mnXOffset = 0; // if GrabFocus before while size was still wrong
ImplAlign();
- if ( !mpSubEdit )
+ if ( !mpSubEdit.get() )
ImplShowCursor( false );
}
// update background (eventual SetPaintTransparent)
@@ -2208,7 +2218,7 @@ void Edit::StateChanged( StateChangedType nType )
}
else if ( nType == StateChangedType::ENABLE )
{
- if ( !mpSubEdit )
+ if ( !mpSubEdit.get() )
{
// change text color only
ImplInvalidateOrRepaint();
@@ -2255,7 +2265,7 @@ void Edit::StateChanged( StateChangedType nType )
}
else if ( nType == StateChangedType::ZOOM )
{
- if ( !mpSubEdit )
+ if ( !mpSubEdit.get() )
{
ImplInitSettings( true, false, false );
ImplShowCursor( true );
@@ -2264,7 +2274,7 @@ void Edit::StateChanged( StateChangedType nType )
}
else if ( nType == StateChangedType::CONTROLFONT )
{
- if ( !mpSubEdit )
+ if ( !mpSubEdit.get() )
{
ImplInitSettings( true, false, false );
ImplShowCursor();
@@ -2273,7 +2283,7 @@ void Edit::StateChanged( StateChangedType nType )
}
else if ( nType == StateChangedType::CONTROLFOREGROUND )
{
- if ( !mpSubEdit )
+ if ( !mpSubEdit.get() )
{
ImplInitSettings( false, true, false );
Invalidate();
@@ -2281,7 +2291,7 @@ void Edit::StateChanged( StateChangedType nType )
}
else if ( nType == StateChangedType::CONTROLBACKGROUND )
{
- if ( !mpSubEdit )
+ if ( !mpSubEdit.get() )
{
ImplInitSettings( false, false, true );
Invalidate();
@@ -2298,7 +2308,7 @@ void Edit::DataChanged( const DataChangedEvent& rDCEvt )
((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
(rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
{
- if ( !mpSubEdit )
+ if ( !mpSubEdit.get() )
{
ImplInitSettings( true, true, true );
ImplShowCursor( true );
@@ -2431,7 +2441,7 @@ void Edit::EnableUpdateData( sal_uLong nTimeout )
void Edit::SetEchoChar( sal_Unicode c )
{
mcEchoChar = c;
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->SetEchoChar( c );
}
@@ -2440,7 +2450,7 @@ void Edit::SetReadOnly( bool bReadOnly )
if ( mbReadOnly != bool(bReadOnly) )
{
mbReadOnly = bReadOnly;
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->SetReadOnly( bReadOnly );
StateChanged( StateChangedType::READONLY );
@@ -2452,7 +2462,7 @@ void Edit::SetInsertMode( bool bInsert )
if ( bInsert != mbInsertMode )
{
mbInsertMode = bInsert;
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->SetInsertMode( bInsert );
else
ImplShowCursor();
@@ -2461,7 +2471,7 @@ void Edit::SetInsertMode( bool bInsert )
bool Edit::IsInsertMode() const
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
return mpSubEdit->IsInsertMode();
else
return mbInsertMode;
@@ -2471,7 +2481,7 @@ void Edit::SetMaxTextLen(sal_Int32 nMaxLen)
{
mnMaxTextLen = nMaxLen > 0 ? nMaxLen : EDIT_NOLIMIT;
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->SetMaxTextLen( mnMaxTextLen );
else
{
@@ -2486,7 +2496,7 @@ void Edit::SetSelection( const Selection& rSelection )
// directly afterwards which would change the selection again
if ( IsTracking() )
EndTracking();
- else if ( mpSubEdit && mpSubEdit->IsTracking() )
+ else if ( mpSubEdit.get() && mpSubEdit->IsTracking() )
mpSubEdit->EndTracking();
ImplSetSelection( rSelection );
@@ -2494,7 +2504,7 @@ void Edit::SetSelection( const Selection& rSelection )
void Edit::ImplSetSelection( const Selection& rSelection, bool bPaint )
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->ImplSetSelection( rSelection );
else
{
@@ -2556,7 +2566,7 @@ void Edit::ImplSetSelection( const Selection& rSelection, bool bPaint )
const Selection& Edit::GetSelection() const
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
return mpSubEdit->GetSelection();
else
return maSelection;
@@ -2564,7 +2574,7 @@ const Selection& Edit::GetSelection() const
void Edit::ReplaceSelected( const OUString& rStr )
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->ReplaceSelected( rStr );
else
ImplInsertText( rStr );
@@ -2572,7 +2582,7 @@ void Edit::ReplaceSelected( const OUString& rStr )
void Edit::DeleteSelected()
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->DeleteSelected();
else
{
@@ -2583,7 +2593,7 @@ void Edit::DeleteSelected()
OUString Edit::GetSelected() const
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
return mpSubEdit->GetSelected();
else
{
@@ -2619,7 +2629,7 @@ void Edit::Paste()
void Edit::Undo()
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->Undo();
else
{
@@ -2644,7 +2654,7 @@ void Edit::SetText( const OUString& rStr )
void Edit::SetText( const OUString& rStr, const Selection& rSelection )
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->SetText( rStr, rSelection );
else
ImplSetText( rStr, &rSelection );
@@ -2652,7 +2662,7 @@ void Edit::SetText( const OUString& rStr, const Selection& rSelection )
OUString Edit::GetText() const
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
return mpSubEdit->GetText();
else
return maText.toString();
@@ -2660,7 +2670,7 @@ OUString Edit::GetText() const
void Edit::SetPlaceholderText( const OUString& rStr )
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->SetPlaceholderText( rStr );
else if ( maPlaceholderText != rStr )
{
@@ -2672,7 +2682,7 @@ void Edit::SetPlaceholderText( const OUString& rStr )
OUString Edit::GetPlaceholderText() const
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
return mpSubEdit->GetPlaceholderText();
return maPlaceholderText;
@@ -2680,7 +2690,7 @@ OUString Edit::GetPlaceholderText() const
void Edit::SetModifyFlag()
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->mbModified = true;
else
mbModified = true;
@@ -2688,16 +2698,17 @@ void Edit::SetModifyFlag()
void Edit::ClearModifyFlag()
{
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
mpSubEdit->mbModified = false;
else
mbModified = false;
}
-void Edit::SetSubEdit( Edit* pEdit )
+void Edit::SetSubEdit( VclReference<Edit> pEdit )
{
+ mpSubEdit.disposeAndClear();
mpSubEdit = pEdit;
- if ( mpSubEdit )
+ if ( mpSubEdit.get() )
{
SetPointer( POINTER_ARROW ); // Nur das SubEdit hat den BEAM...
mpSubEdit->mbIsSubEdit = true;
@@ -2793,7 +2804,7 @@ Size Edit::CalcSize(sal_Int32 nChars) const
sal_Int32 Edit::GetMaxVisChars() const
{
- const vcl::Window* pW = mpSubEdit ? mpSubEdit : this;
+ const vcl::Window* pW = mpSubEdit.get() ? mpSubEdit.get() : this;
sal_Int32 nOutWidth = pW->GetOutputSizePixel().Width();
sal_Int32 nCharWidth = GetTextWidth( OUString('x') );
return nCharWidth ? nOutWidth/nCharWidth : 0;
@@ -3025,7 +3036,7 @@ void Edit::dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEv
OUString Edit::GetSurroundingText() const
{
- if (mpSubEdit)
+ if (mpSubEdit.get())
return mpSubEdit->GetSurroundingText();
return maText.toString();
}
diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx
index 25de8d34c957..bc16a6e2ce49 100644
--- a/vcl/source/window/mouse.cxx
+++ b/vcl/source/window/mouse.cxx
@@ -657,6 +657,8 @@ void Window::ImplStartDnd()
Reference< css::datatransfer::dnd::XDropTarget > Window::GetDropTarget()
{
+ if( !mpWindowImpl )
+ return Reference< css::datatransfer::dnd::XDropTarget >();
if( ! mpWindowImpl->mxDNDListenerContainer.is() )
{
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index e6672875f7c4..bc02ec1de7d2 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -1317,6 +1317,8 @@ bool Window::IsWait() const
vcl::Cursor* Window::GetCursor() const
{
+ if (!mpWindowImpl)
+ return NULL;
return mpWindowImpl->mpCursor;
}