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:
parent
e9c51a1fdc
commit
142c5ef9dd
@ -500,7 +500,7 @@ void QLineEdit::setClearButtonEnabled(bool enable)
|
|||||||
} else {
|
} else {
|
||||||
QAction *clearAction = findChild<QAction *>(QLatin1String(clearButtonActionNameC));
|
QAction *clearAction = findChild<QAction *>(QLatin1String(clearButtonActionNameC));
|
||||||
Q_ASSERT(clearAction);
|
Q_ASSERT(clearAction);
|
||||||
removeAction(clearAction);
|
d->removeAction(clearAction);
|
||||||
delete clearAction;
|
delete clearAction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1439,7 +1439,7 @@ bool QLineEdit::event(QEvent * e)
|
|||||||
d->setCursorVisible(true);
|
d->setCursorVisible(true);
|
||||||
}
|
}
|
||||||
} else if (e->type() == QEvent::ActionRemoved) {
|
} 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) {
|
} else if (e->type() == QEvent::Resize) {
|
||||||
d->positionSideWidgets();
|
d->positionSideWidgets();
|
||||||
}
|
}
|
||||||
|
@ -445,10 +445,9 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QLineEditPrivate::removeAction(const QActionEvent *e)
|
void QLineEditPrivate::removeAction(QAction *action)
|
||||||
{
|
{
|
||||||
Q_Q(QLineEdit);
|
Q_Q(QLineEdit);
|
||||||
QAction *action = e->action();
|
|
||||||
const PositionIndexPair positionIndex = findSideWidget(action);
|
const PositionIndexPair positionIndex = findSideWidget(action);
|
||||||
if (positionIndex.second == -1)
|
if (positionIndex.second == -1)
|
||||||
return;
|
return;
|
||||||
|
@ -196,7 +196,7 @@ public:
|
|||||||
QString placeholderText;
|
QString placeholderText;
|
||||||
|
|
||||||
QWidget *addAction(QAction *newAction, QAction *before, QLineEdit::ActionPosition, int flags = 0);
|
QWidget *addAction(QAction *newAction, QAction *before, QLineEdit::ActionPosition, int flags = 0);
|
||||||
void removeAction(const QActionEvent *e);
|
void removeAction(QAction *action);
|
||||||
QSize iconSize() const;
|
QSize iconSize() const;
|
||||||
QIcon clearButtonIcon() const;
|
QIcon clearButtonIcon() const;
|
||||||
void positionSideWidgets();
|
void positionSideWidgets();
|
||||||
|
Loading…
Reference in New Issue
Block a user