tst_QCompleter: fix memleak in hideWidget()

QLineEdit::setCompleter() doesn't reparent the completer under the
line edit, so this test function leaked the object (and with it,
"22260 byte(s) leaked in 214 allocation(s)"; seriously, what does a
QCompleter do with 20+KiB of memory!?).

Fix by giving the completer the line edit as parent.

Amends 24859d7deaf995e992f0d9439a1c476126d5f654.

Pick-to: 6.9 6.8
Change-Id: Ic14a32c982dd4c75ae527188e53a7f20af714038
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Marc Mutz 2025-03-25 18:52:08 +01:00
parent ad0d6be778
commit bdd2cefcf3

View File

@ -1209,7 +1209,7 @@ void tst_QCompleter::hideWidget()
w.setLayout(new QVBoxLayout);
QLineEdit edit;
edit.setCompleter(new QCompleter({ "foo", "bar" }));
edit.setCompleter(new QCompleter({ "foo", "bar" }, &edit));
w.layout()->addWidget(&edit);