Skip to content

Commit 012ad1c

Browse files
committedOct 23, 2018
Revert "Do not delete the clear action (and don't crash)"
This reverts commit 5c28693. Because regresses fb5caa7 See also Fixes #18537
1 parent 5c28693 commit 012ad1c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed
 

‎src/gui/qgsfilterlineedit.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ QgsFilterLineEdit::QgsFilterLineEdit( QWidget *parent, const QString &nullValue
3737

3838
connect( this, &QLineEdit::textChanged, this,
3939
&QgsFilterLineEdit::onTextChanged );
40-
4140
}
4241

4342
void QgsFilterLineEdit::setShowClearButton( bool visible )
@@ -72,8 +71,17 @@ void QgsFilterLineEdit::updateClearIcon()
7271
addAction( mClearAction, QLineEdit::TrailingPosition );
7372
connect( mClearAction, &QAction::triggered, this, &QgsFilterLineEdit::clearValue );
7473
}
75-
if ( mClearAction )
76-
mClearAction->setVisible( showClear );
74+
else if ( !showClear && mClearAction )
75+
{
76+
// pretty freakin weird... seems the deleteLater call on the mClearAction
77+
// isn't sufficient to actually remove the action from the line edit, and
78+
// a kind of "ghost" action gets left behind... resulting in duplicate
79+
// clear actions appearing if later we re-create the action.
80+
// in summary: don't remove this "removeAction" call!
81+
removeAction( mClearAction );
82+
mClearAction->deleteLater();
83+
mClearAction = nullptr;
84+
}
7785
}
7886

7987
void QgsFilterLineEdit::focusInEvent( QFocusEvent *e )

0 commit comments

Comments
 (0)
Please sign in to comment.