diff --git a/autotests/kurlcomboboxtest.h b/autotests/kurlcomboboxtest.h --- a/autotests/kurlcomboboxtest.h +++ b/autotests/kurlcomboboxtest.h @@ -29,6 +29,7 @@ private Q_SLOTS: void testTextForItem(); void testTextForItem_data(); + void testSetUrlMultipleTimes(); }; #endif //KURLCOMBOBOXTEST_H diff --git a/autotests/kurlcomboboxtest.cpp b/autotests/kurlcomboboxtest.cpp --- a/autotests/kurlcomboboxtest.cpp +++ b/autotests/kurlcomboboxtest.cpp @@ -45,3 +45,10 @@ QCOMPARE(combo.itemText(0), expectedText); } + +void KUrlComboBoxTest::testSetUrlMultipleTimes() +{ + KUrlComboBox combo(KUrlComboBox::Directories); + combo.setUrl(QUrl("http://kde.org")); + combo.setUrl(QUrl("http://www.kde.org")); +} diff --git a/src/widgets/kurlcombobox.cpp b/src/widgets/kurlcombobox.cpp --- a/src/widgets/kurlcombobox.cpp +++ b/src/widgets/kurlcombobox.cpp @@ -276,6 +276,7 @@ // first remove the old item if (d->urlAdded) { Q_ASSERT(!d->itemList.isEmpty()); + delete d->itemList.last(); d->itemList.removeLast(); d->urlAdded = false; }