Kaydet (Commit) e35bc27f authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Meeks

vclwidget: make sure we have an explicit destructor

Change-Id: I50490ad8957e8069e72e855f0f5a3b694218fd6b
üst 683cb121
......@@ -76,7 +76,7 @@ void VCLXAccessibleBox::ProcessWindowChildEvent( const VclWindowEvent& rVclWindo
if (m_aBoxType==COMBOBOX)
{
VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
if ( ( pComboBox != NULL ) && ( pChildWindow != NULL ) )
if ( ( pComboBox != nullptr ) && ( pChildWindow != NULL ) )
if (pChildWindow == pComboBox->GetSubEdit())
{
if (rVclWindowEvent.GetId() == VCLEVENT_WINDOW_SHOW)
......@@ -328,7 +328,7 @@ Reference<XAccessible> SAL_CALL VCLXAccessibleBox::getAccessibleChild (sal_Int32
if (m_aBoxType==COMBOBOX)
{
VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
if (pComboBox!=NULL && pComboBox->GetSubEdit()!=NULL)
if (pComboBox!=nullptr && pComboBox->GetSubEdit()!=NULL)
//Set the edit's acc name the same as parent
{
pComboBox->GetSubEdit()->SetAccessibleName(getAccessibleName());
......@@ -399,7 +399,7 @@ sal_Bool SAL_CALL VCLXAccessibleBox::doAccessibleAction (sal_Int32 nIndex)
if (m_aBoxType == COMBOBOX)
{
VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
if (pComboBox != NULL)
if (pComboBox != nullptr)
{
pComboBox->ToggleDropDown();
bNotify = true;
......@@ -408,7 +408,7 @@ sal_Bool SAL_CALL VCLXAccessibleBox::doAccessibleAction (sal_Int32 nIndex)
else if (m_aBoxType == LISTBOX)
{
VclPtr< ListBox > pListBox = GetAs< ListBox >();
if (pListBox != NULL)
if (pListBox != nullptr)
{
pListBox->ToggleDropDown();
bNotify = true;
......@@ -533,7 +533,7 @@ void VCLXAccessibleBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& r
OUString sText;
sal_Int32 nEntryCount = 0;
VclPtr< ComboBox > pComboBox = GetAs< ComboBox >();
if (pComboBox != NULL)
if (pComboBox != nullptr)
{
Edit* pSubEdit = pComboBox->GetSubEdit();
if ( pSubEdit)
......@@ -547,7 +547,7 @@ void VCLXAccessibleBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& r
{
sal_Int32 nSelectedEntryCount = 0;
VclPtr< ListBox > pListBox = GetAs< ListBox >();
if (pListBox != NULL && pListBox->GetEntryCount() > 0)
if (pListBox != nullptr && pListBox->GetEntryCount() > 0)
{
nSelectedEntryCount = pListBox->GetSelectEntryCount();
if ( nSelectedEntryCount == 0)
......
......@@ -270,6 +270,13 @@ bool VCLWidgets::VisitFieldDecl(const FieldDecl * fieldDecl) {
fieldDecl->getLocation())
<< fieldDecl->getSourceRange();
}
if (!pParentRecordDecl->hasUserDeclaredDestructor()) {
report(
DiagnosticsEngine::Warning,
"vcl::Window subclass with a VclPtr field MUST have an explicit destructor.",
fieldDecl->getLocation())
<< fieldDecl->getSourceRange();
}
}
return true;
......@@ -294,13 +301,6 @@ bool VCLWidgets::VisitParmVarDecl(ParmVarDecl const * pvDecl)
{
return true;
}
if (!pvDecl->getType()->isReferenceType() && pvDecl->getType().getAsString().find("VclPtr") != std::string::npos) {
report(
DiagnosticsEngine::Warning,
"vcl::Window subclass passed as a VclPtr parameter, should be passed as a raw pointer.",
pvDecl->getCanonicalDecl()->getLocation())
<< pvDecl->getCanonicalDecl()->getSourceRange();
}
return true;
}
......@@ -363,14 +363,6 @@ bool VCLWidgets::VisitFunctionDecl( const FunctionDecl* functionDecl )
&& pMethodDecl->getParent()->getQualifiedNameAsString() == "vcl::Window") {
return true;
}
QualType t1 { compat::getReturnType(*functionDecl) };
if (t1.getAsString().find("VclPtr") == 0) {
report(
DiagnosticsEngine::Warning,
"VclPtr declared as a return type from a method/function, should be passed as a raw pointer.",
functionDecl->getLocation())
<< functionDecl->getSourceRange();
}
if (functionDecl->hasBody() && pMethodDecl && isDerivedFromWindow(pMethodDecl->getParent())) {
// check the last thing that the dispose() method does, is to call into the superclass dispose method
if (pMethodDecl->getNameAsString() == "dispose") {
......
......@@ -626,6 +626,7 @@ private:
VclPtr<EventBoxHelper> m_aEventBoxHelper;
protected:
virtual void dispose() SAL_OVERRIDE;
virtual ~VclEventBox();
public:
VclEventBox(vcl::Window* pParent)
: VclBin(pParent)
......
......@@ -501,7 +501,7 @@ public:
protected:
/** This is intended to be used to clear any locally held references to other Window-subclass objects */
virtual void dispose();
virtual void dispose() SAL_OVERRIDE;
SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData );
......
......@@ -217,6 +217,7 @@ public:
void SetInfoText( const OUString& rStr );
private:
virtual void dispose() SAL_OVERRIDE;
virtual ~DbgInfoDialog() { disposeOnce(); }
};
class DbgDialog : public ModalDialog
......@@ -238,6 +239,7 @@ public:
void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
private:
virtual void dispose() SAL_OVERRIDE;
virtual ~DbgDialog() { disposeOnce(); }
};
DbgDialog::DbgDialog() :
......@@ -831,7 +833,7 @@ void DbgGUIStart()
if ( pData )
{
std::unique_ptr<DbgDialog> xDialog(new DbgDialog);
VclPtr<DbgDialog> pDialog(new DbgDialog);
// we switch off dialog tests for the debug dialog
sal_uLong nOldFlags = pData->nTestFlags;
pData->nTestFlags &= ~DBG_TEST_DIALOG;
......
......@@ -1903,6 +1903,11 @@ void VclEventBox::Command(const CommandEvent&)
//discard events by default to block them reaching children
}
VclEventBox::~VclEventBox()
{
disposeOnce();
}
void VclEventBox::dispose()
{
m_aEventBoxHelper.disposeAndClear();
......
......@@ -316,6 +316,7 @@ public:
virtual void setText( const OUString & ) SAL_OVERRIDE;
virtual void show( bool bShow, I18NStatus::ShowReason eReason ) SAL_OVERRIDE;
virtual void toggle( bool bOn ) SAL_OVERRIDE;
virtual ~IIIMPStatusWindow() { disposeOnce(); }
virtual void dispose() SAL_OVERRIDE;
void layout();
......
......@@ -108,6 +108,7 @@ public:
virtual void Resize() SAL_OVERRIDE;
virtual bool Close() SAL_OVERRIDE;
virtual ~MyWin() { disposeOnce(); }
virtual void dispose() SAL_OVERRIDE;
void parseList( const OString& rList );
......
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