QLineEdit: Fix potential crash when removing the clear button.

Remove it from the side actions list.

Task-number: QTBUG-34315
Change-Id: I70063351193b504f8656e903896d155ac74f73a6
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Friedemann Kleint 2013-10-25 12:37:30 +02:00 committed by The Qt Project
parent e9c51a1fdc
commit 142c5ef9dd
3 changed files with 4 additions and 5 deletions

View File

@ -500,7 +500,7 @@ void QLineEdit::setClearButtonEnabled(bool enable)
} else {
QAction *clearAction = findChild<QAction *>(QLatin1String(clearButtonActionNameC));
Q_ASSERT(clearAction);
removeAction(clearAction);
d->removeAction(clearAction);
delete clearAction;
}
}
@ -1439,7 +1439,7 @@ bool QLineEdit::event(QEvent * e)
d->setCursorVisible(true);
}
} else if (e->type() == QEvent::ActionRemoved) {
d->removeAction(static_cast<QActionEvent *>(e));
d->removeAction(static_cast<QActionEvent *>(e)->action());
} else if (e->type() == QEvent::Resize) {
d->positionSideWidgets();
}

View File

@ -445,10 +445,9 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE
return w;
}
void QLineEditPrivate::removeAction(const QActionEvent *e)
void QLineEditPrivate::removeAction(QAction *action)
{
Q_Q(QLineEdit);
QAction *action = e->action();
const PositionIndexPair positionIndex = findSideWidget(action);
if (positionIndex.second == -1)
return;

View File

@ -196,7 +196,7 @@ public:
QString placeholderText;
QWidget *addAction(QAction *newAction, QAction *before, QLineEdit::ActionPosition, int flags = 0);
void removeAction(const QActionEvent *e);
void removeAction(QAction *action);
QSize iconSize() const;
QIcon clearButtonIcon() const;
void positionSideWidgets();