Plug remaining leaks in tests/auto/widgets/util
In tst_QCompleter, two completers were leaked because they had no parent and setCompleter() calls don't reparent. Fixed by giving them parents. In tst_QUndo*, fix lots of leaked QActions by storing them in a QScopedPointer. There were some half-hearted attempts to clean them up with manual deletes, but I ported these to scoped pointers, too, to make the code more robust in the face of failures. This fixes the remaining errors in GCC 6.1 Linux ASan runs of tests/auto/widgets/util. Change-Id: Icc5248cc9cf4514540915924df1c4d9e09c071fa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
f43c9697bc
commit
ad1555be7f
@ -1228,7 +1228,7 @@ void tst_QCompleter::task178797_activatedOnReturn()
|
||||
words << "foobar1" << "foobar2";
|
||||
QLineEdit ledit;
|
||||
setFrameless(&ledit);
|
||||
QCompleter *completer = new QCompleter(words);
|
||||
QCompleter *completer = new QCompleter(words, &ledit);
|
||||
ledit.setCompleter(completer);
|
||||
QSignalSpy spy(completer, SIGNAL(activated(QString)));
|
||||
QCOMPARE(spy.count(), 0);
|
||||
@ -1335,7 +1335,7 @@ public:
|
||||
|
||||
task250064_TextEdit()
|
||||
{
|
||||
completer = new QCompleter;
|
||||
completer = new QCompleter(this);
|
||||
completer->setWidget(this);
|
||||
}
|
||||
|
||||
|
@ -382,8 +382,8 @@ static QString glue(const QString &s1, const QString &s2)
|
||||
void tst_QUndoGroup::checkSignals()
|
||||
{
|
||||
QUndoGroup group;
|
||||
QAction *undo_action = group.createUndoAction(0, QString("foo"));
|
||||
QAction *redo_action = group.createRedoAction(0, QString("bar"));
|
||||
const QScopedPointer<QAction> undo_action(group.createUndoAction(0, QString("foo")));
|
||||
const QScopedPointer<QAction> redo_action(group.createRedoAction(0, QString("bar")));
|
||||
QSignalSpy indexChangedSpy(&group, SIGNAL(indexChanged(int)));
|
||||
QSignalSpy cleanChangedSpy(&group, SIGNAL(cleanChanged(bool)));
|
||||
QSignalSpy canUndoChangedSpy(&group, SIGNAL(canUndoChanged(bool)));
|
||||
@ -595,9 +595,6 @@ void tst_QUndoGroup::checkSignals()
|
||||
true, // indexChanged
|
||||
true, // undoChanged
|
||||
true) // redoChanged
|
||||
|
||||
delete undo_action;
|
||||
delete redo_action;
|
||||
}
|
||||
|
||||
void tst_QUndoGroup::addStackAndDie()
|
||||
@ -634,8 +631,8 @@ void tst_QUndoGroup::commandTextFormat()
|
||||
qApp->installTranslator(&translator);
|
||||
|
||||
QUndoGroup group;
|
||||
QAction *undo_action = group.createUndoAction(0);
|
||||
QAction *redo_action = group.createRedoAction(0);
|
||||
const QScopedPointer<QAction> undo_action(group.createUndoAction(0));
|
||||
const QScopedPointer<QAction> redo_action(group.createRedoAction(0));
|
||||
|
||||
QCOMPARE(undo_action->text(), QString("Undo-default-text"));
|
||||
QCOMPARE(redo_action->text(), QString("Redo-default-text"));
|
||||
|
@ -262,8 +262,8 @@ static QString glue(const QString &s1, const QString &s2)
|
||||
static void checkState(QSignalSpy &redoTextChangedSpy,
|
||||
QSignalSpy &canRedoChangedSpy,
|
||||
QSignalSpy &undoTextChangedSpy,
|
||||
QAction *const redoAction,
|
||||
QAction *const undoAction,
|
||||
const QScopedPointer<QAction> &redoAction,
|
||||
const QScopedPointer<QAction> &undoAction,
|
||||
QSignalSpy &canUndoChangedSpy,
|
||||
QSignalSpy &cleanChangedSpy,
|
||||
QSignalSpy &indexChangedSpy,
|
||||
@ -332,8 +332,8 @@ static void checkState(QSignalSpy &redoTextChangedSpy,
|
||||
void tst_QUndoStack::undoRedo()
|
||||
{
|
||||
QUndoStack stack;
|
||||
QAction *undoAction = stack.createUndoAction(0, QString("foo"));
|
||||
QAction *redoAction = stack.createRedoAction(0, QString("bar"));
|
||||
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
|
||||
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
|
||||
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
|
||||
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
|
||||
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
|
||||
@ -693,8 +693,8 @@ void tst_QUndoStack::undoRedo()
|
||||
void tst_QUndoStack::setIndex()
|
||||
{
|
||||
QUndoStack stack;
|
||||
QAction *undoAction = stack.createUndoAction(0, QString("foo"));
|
||||
QAction *redoAction = stack.createRedoAction(0, QString("bar"));
|
||||
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
|
||||
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
|
||||
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
|
||||
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
|
||||
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
|
||||
@ -957,8 +957,8 @@ void tst_QUndoStack::setIndex()
|
||||
void tst_QUndoStack::setClean()
|
||||
{
|
||||
QUndoStack stack;
|
||||
QAction *undoAction = stack.createUndoAction(0, QString("foo"));
|
||||
QAction *redoAction = stack.createRedoAction(0, QString("bar"));
|
||||
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
|
||||
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
|
||||
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
|
||||
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
|
||||
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
|
||||
@ -1210,8 +1210,8 @@ void tst_QUndoStack::setClean()
|
||||
void tst_QUndoStack::clear()
|
||||
{
|
||||
QUndoStack stack;
|
||||
QAction *undoAction = stack.createUndoAction(this, QString("foo"));
|
||||
QAction *redoAction = stack.createRedoAction(this, QString("bar"));
|
||||
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
|
||||
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
|
||||
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
|
||||
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
|
||||
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
|
||||
@ -1408,8 +1408,8 @@ void tst_QUndoStack::clear()
|
||||
void tst_QUndoStack::childCommand()
|
||||
{
|
||||
QUndoStack stack;
|
||||
QAction *undoAction = stack.createUndoAction(0, QString("foo"));
|
||||
QAction *redoAction = stack.createRedoAction(0, QString("bar"));
|
||||
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
|
||||
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
|
||||
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
|
||||
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
|
||||
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
|
||||
@ -1513,16 +1513,13 @@ void tst_QUndoStack::childCommand()
|
||||
true, // indexChanged
|
||||
true, // undoChanged
|
||||
true); // redoChanged
|
||||
|
||||
delete undoAction;
|
||||
delete redoAction;
|
||||
}
|
||||
|
||||
void tst_QUndoStack::macroBeginEnd()
|
||||
{
|
||||
QUndoStack stack;
|
||||
QAction *undoAction = stack.createUndoAction(0, QString("foo"));
|
||||
QAction *redoAction = stack.createRedoAction(0, QString("bar"));
|
||||
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
|
||||
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
|
||||
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
|
||||
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
|
||||
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
|
||||
@ -1983,16 +1980,13 @@ void tst_QUndoStack::macroBeginEnd()
|
||||
true, // indexChanged
|
||||
true, // undoChanged
|
||||
true); // redoChanged
|
||||
|
||||
delete undoAction;
|
||||
delete redoAction;
|
||||
}
|
||||
|
||||
void tst_QUndoStack::compression()
|
||||
{
|
||||
QUndoStack stack;
|
||||
QAction *undoAction = stack.createUndoAction(0, QString("foo"));
|
||||
QAction *redoAction = stack.createRedoAction(0, QString("bar"));
|
||||
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
|
||||
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
|
||||
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
|
||||
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
|
||||
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
|
||||
@ -2428,16 +2422,13 @@ void tst_QUndoStack::compression()
|
||||
true, // indexChanged
|
||||
true, // undoChanged
|
||||
true); // redoChanged
|
||||
|
||||
delete undoAction;
|
||||
delete redoAction;
|
||||
}
|
||||
|
||||
void tst_QUndoStack::undoLimit()
|
||||
{
|
||||
QUndoStack stack;
|
||||
QAction *undoAction = stack.createUndoAction(0, QString("foo"));
|
||||
QAction *redoAction = stack.createRedoAction(0, QString("bar"));
|
||||
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo")));
|
||||
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar")));
|
||||
QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int)));
|
||||
QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool)));
|
||||
QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool)));
|
||||
@ -2977,8 +2968,8 @@ void tst_QUndoStack::commandTextFormat()
|
||||
qApp->installTranslator(&translator);
|
||||
|
||||
QUndoStack stack;
|
||||
QAction *undo_action = stack.createUndoAction(0);
|
||||
QAction *redo_action = stack.createRedoAction(0);
|
||||
const QScopedPointer<QAction> undo_action(stack.createUndoAction(0));
|
||||
const QScopedPointer<QAction> redo_action(stack.createRedoAction(0));
|
||||
|
||||
QCOMPARE(undo_action->text(), QString("Undo-default-text"));
|
||||
QCOMPARE(redo_action->text(), QString("Redo-default-text"));
|
||||
@ -3005,8 +2996,8 @@ void tst_QUndoStack::commandTextFormat()
|
||||
void tst_QUndoStack::separateUndoText()
|
||||
{
|
||||
QUndoStack stack;
|
||||
QAction *undo_action = stack.createUndoAction(0);
|
||||
QAction *redo_action = stack.createRedoAction(0);
|
||||
const QScopedPointer<QAction> undo_action(stack.createUndoAction(0));
|
||||
const QScopedPointer<QAction> redo_action(stack.createRedoAction(0));
|
||||
|
||||
QUndoCommand *command1 = new IdleCommand();
|
||||
QUndoCommand *command2 = new IdleCommand();
|
||||
|
Loading…
Reference in New Issue
Block a user