disconnect from visibleChanged when being destructed
This commit is contained in:
parent
0d9dbf4c58
commit
9b0dd47cae
@ -79,6 +79,28 @@ class QskDialogButtonBox::PrivateData
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void connectButton( QskDialogButtonBox* box,
|
||||||
|
QskPushButton* button, bool on )
|
||||||
|
{
|
||||||
|
if ( on )
|
||||||
|
{
|
||||||
|
connect( button, &QskPushButton::clicked,
|
||||||
|
box, &QskDialogButtonBox::onButtonClicked,
|
||||||
|
Qt::UniqueConnection );
|
||||||
|
|
||||||
|
connect( button, &QskPushButton::visibleChanged,
|
||||||
|
box, &QskDialogButtonBox::invalidateLayout,
|
||||||
|
Qt::UniqueConnection );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disconnect( button, &QskPushButton::clicked,
|
||||||
|
box, &QskDialogButtonBox::onButtonClicked );
|
||||||
|
|
||||||
|
disconnect( button, &QskPushButton::visibleChanged,
|
||||||
|
box, &QskDialogButtonBox::invalidateLayout );
|
||||||
|
}
|
||||||
|
}
|
||||||
LayoutEngine layoutEngine;
|
LayoutEngine layoutEngine;
|
||||||
|
|
||||||
QVector< QskPushButton* > buttons[ QskDialog::NActionRoles ];
|
QVector< QskPushButton* > buttons[ QskDialog::NActionRoles ];
|
||||||
@ -107,6 +129,18 @@ QskDialogButtonBox::QskDialogButtonBox( Qt::Orientation orientation, QQuickItem*
|
|||||||
|
|
||||||
QskDialogButtonBox::~QskDialogButtonBox()
|
QskDialogButtonBox::~QskDialogButtonBox()
|
||||||
{
|
{
|
||||||
|
for ( int i = 0; i < QskDialog::NActionRoles; i++ )
|
||||||
|
{
|
||||||
|
for ( auto button : qskAsConst( m_data->buttons[ i ] ) )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
The destructor of QQuickItem sets the parentItem of
|
||||||
|
all children to nullptr, what leads to visibleChanged
|
||||||
|
signals. So we better disconnect first.
|
||||||
|
*/
|
||||||
|
PrivateData::connectButton( this, button, false );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskDialogButtonBox::setOrientation( Qt::Orientation orientation )
|
void QskDialogButtonBox::setOrientation( Qt::Orientation orientation )
|
||||||
@ -302,11 +336,7 @@ void QskDialogButtonBox::addButton(
|
|||||||
*/
|
*/
|
||||||
button->setParentItem( this );
|
button->setParentItem( this );
|
||||||
|
|
||||||
connect( button, &QskPushButton::clicked,
|
PrivateData::connectButton( this, button, true );
|
||||||
this, &QskDialogButtonBox::onButtonClicked );
|
|
||||||
|
|
||||||
connect( button, &QskPushButton::visibleChanged,
|
|
||||||
this, &QskDialogButtonBox::invalidateLayout );
|
|
||||||
|
|
||||||
m_data->buttons[ role ].removeOne( button );
|
m_data->buttons[ role ].removeOne( button );
|
||||||
m_data->buttons[ role ] += button;
|
m_data->buttons[ role ] += button;
|
||||||
@ -330,11 +360,7 @@ void QskDialogButtonBox::removeButton( QskPushButton* button )
|
|||||||
{
|
{
|
||||||
if ( m_data->buttons[ i ].removeOne( button ) )
|
if ( m_data->buttons[ i ].removeOne( button ) )
|
||||||
{
|
{
|
||||||
disconnect( button, &QskPushButton::clicked,
|
PrivateData::connectButton( this, button, false );
|
||||||
this, &QskDialogButtonBox::onButtonClicked );
|
|
||||||
|
|
||||||
disconnect( button, &QskPushButton::visibleChanged,
|
|
||||||
this, &QskDialogButtonBox::invalidateLayout );
|
|
||||||
|
|
||||||
invalidateLayout();
|
invalidateLayout();
|
||||||
|
|
||||||
|
@ -71,9 +71,16 @@ QskLinearBox::~QskLinearBox()
|
|||||||
for ( int i = 0; i < engine.count(); i++ )
|
for ( int i = 0; i < engine.count(); i++ )
|
||||||
{
|
{
|
||||||
if ( auto item = engine.itemAt( i ) )
|
if ( auto item = engine.itemAt( i ) )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
The destructor of QQuickItem sets the parentItem of
|
||||||
|
all children to nullptr, what leads to visibleChanged
|
||||||
|
signals. So we better disconnect first.
|
||||||
|
*/
|
||||||
setItemActive( item, false );
|
setItemActive( item, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int QskLinearBox::elementCount() const
|
int QskLinearBox::elementCount() const
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user