Skip to content

Commit

Permalink
Summary: Fix crash when closing dialog to edit filter
Browse files Browse the repository at this point in the history
BUG: 421456
  • Loading branch information
pcgomes committed Jul 30, 2020
1 parent fb5b5ab commit df34fd7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/dialogs/EditFilterDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ EditFilterDialog::filterForToken( Token *token )
newFilter.inverted = false;

m_filters.insert( token, newFilter );
connect( token, &Token::destroyed,
this, &EditFilterDialog::slotTokenDestroyed );
connect( token, &Token::removed,
this, &EditFilterDialog::slotTokenRemoved );
}

return m_filters[token];
Expand All @@ -168,11 +168,11 @@ EditFilterDialog::slotTokenSelected( Token *token )
}

void
EditFilterDialog::slotTokenDestroyed( QObject *token )
EditFilterDialog::slotTokenRemoved( Token *token )
{
DEBUG_BLOCK

m_filters.take( qobject_cast<Token*>(token) );
m_filters.take( token );
if( m_curToken == token )
{
m_curToken = 0;
Expand Down Expand Up @@ -451,8 +451,8 @@ EditFilterDialog::updateDropTarget( const QString &text )
? tokenForField( filter.filter.field() )
: SIMPLE_TEXT_CONSTRUCT;
m_filters.insert( nToken, filter );
connect( nToken, &Token::destroyed,
this, &EditFilterDialog::slotTokenDestroyed );
connect( nToken, &Token::removed,
this, &EditFilterDialog::slotTokenRemoved);

m_ui->dropTarget->appendToken( nToken );

Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/EditFilterDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class EditFilterDialog : public QDialog

private Q_SLOTS:
void slotTokenSelected( Token *token );
void slotTokenDestroyed( QObject *token );
void slotTokenRemoved( Token *token );
void slotAttributeChanged( const MetaQueryWidget::Filter &filter );
void slotInvert( bool checked );
void slotSeparatorChange();
Expand Down
9 changes: 4 additions & 5 deletions src/widgets/Token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,12 @@ Token::performDrag()
if( stacked )
hide();

Token *token = this;

QDrag *drag = new QDrag( this );
drag->setMimeData( mimeData() );

// icon for pointer
QPixmap pixmap( token->size() );
token->render( &pixmap );
QPixmap pixmap( size() );
render( &pixmap );
drag->setPixmap( pixmap );
drag->setHotSpot ( pixmap.rect().center() );

Expand All @@ -244,7 +242,8 @@ Token::performDrag()
if( dropAction != Qt::MoveAction && dropAction != Qt::CopyAction ) // dragged out and not just dragged to another position.
{
// TODO: nice poof animation? ;-)
token->deleteLater();
Q_EMIT removed( this );
deleteLater();
}

}
Expand Down
1 change: 1 addition & 0 deletions src/widgets/Token.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Token : public QWidget

Q_SIGNALS:
void changed();
void removed( Token *token );

/** Emitted when the token get's the focus */
void gotFocus( Token* thisToken );
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/TokenDropTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ TokenDropTarget::clear()
{
QList< Token *> allTokens = tokensAtRow();
foreach( Token* token, allTokens )
delete token;
token->deleteLater();;

Q_EMIT changed();
}
Expand Down Expand Up @@ -206,7 +206,7 @@ TokenDropTarget::insertToken( Token *token, int row, int col )

connect( token, &Token::changed, this, &TokenDropTarget::changed );
connect( token, &Token::gotFocus, this, &TokenDropTarget::tokenSelected );
connect( token, &Token::changed, this, &TokenDropTarget::deleteEmptyRows );
connect( token, &Token::removed, this, &TokenDropTarget::deleteEmptyRows );

Q_EMIT changed();
}
Expand Down

0 comments on commit df34fd7

Please sign in to comment.