on xenial help sign in
Fixed leak in UnityMenuModelStackTest
5652796Nick Dedekind
tests/plugins/Unity/Indicators/UnityMenuModelStackTest.cpp+2−9
@@ -43,6 +43,8 @@ private Q_SLOTS:
43 {
43 {
44 delete m_model;
44 delete m_model;
45 m_model = nullptr;
45 m_model = nullptr;
46+ // send deleteLaters to avoid leaks.
47+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
46 }
48 }
47
49
48 void testHeadOnSetHead()
50 void testHeadOnSetHead()
@@ -146,19 +148,10 @@ private Q_SLOTS:
146
148
147 m_model->removeRow(removeIndex);
149 m_model->removeRow(removeIndex);
148
150
149− waitFor([&stack, resultCount]() { return stack.count() == resultCount; }, 1000);
150 QCOMPARE(stack.count(), resultCount);
151 QCOMPARE(stack.count(), resultCount);
151 }
152 }
152
153
153private:
154private:
154− bool waitFor(std::function<bool()> functor, int ms) {
155−
156− QElapsedTimer timer;
157− timer.start();
158− while(!functor() && timer.elapsed() < ms) { QTest::qWait(10); }
159− return functor();
160− }
161−
162 QVariant recuseAddMenu(int subMenuCount, int depth_remaining)
155 QVariant recuseAddMenu(int subMenuCount, int depth_remaining)
163 {
156 {
164 QVariantList rows;
157 QVariantList rows;