From 6078bd7ddc6819d2650435313bb824442bbe033d Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Fri, 23 Nov 2012 12:03:07 -0300 Subject: Fixed QMenumodel behaviour when the GMenuModel is destroyed. --- tests/client/modeltest.cpp | 27 +++++++++++++++++++++++++++ tests/script/menuscript.py | 3 +++ 2 files changed, 30 insertions(+) (limited to 'tests') diff --git a/tests/client/modeltest.cpp b/tests/client/modeltest.cpp index c6b2f0e..0aa4b52 100644 --- a/tests/client/modeltest.cpp +++ b/tests/client/modeltest.cpp @@ -25,6 +25,19 @@ #include #include +extern "C" { +#include +} + +class TestMenuModel : public QMenuModel +{ +public: + TestMenuModel(GMenuModel *other, QObject *parent=0) + : QMenuModel(other, parent) + { + } +}; + class ModelTest : public QObject { Q_OBJECT @@ -242,6 +255,20 @@ private Q_SLOTS: delete model; } + /* + * Test if the model is clearead after GMenuModel be destroyed + */ + void testDestroyGMenuModel() + { + GMenu *menu = g_menu_new(); + g_menu_append(menu, "test-menu0", NULL); + g_menu_append(menu, "test-menu1", NULL); + TestMenuModel model(reinterpret_cast(menu)); + QCOMPARE(model.rowCount(), 2); + + g_object_unref(menu); + QCOMPARE(model.rowCount(), 0); + } }; QTEST_MAIN(ModelTest) diff --git a/tests/script/menuscript.py b/tests/script/menuscript.py index 60cb33b..d25bb30 100644 --- a/tests/script/menuscript.py +++ b/tests/script/menuscript.py @@ -205,6 +205,9 @@ class ActionList(object): if self._ownNameID: Gio.bus_unown_name(self._ownNameID) self._ownNameID = None + + self._root = None + self._rootAction = None self._restore() def _onActionActivated(self, action, parameter): -- cgit v1.2.3 From aa56c7b79317fb88c12fc0573fc23b6939337fe4 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Fri, 23 Nov 2012 14:41:21 -0300 Subject: Take care of object ref internally on QMenumodel, instead of QDBusMenuModel. --- tests/client/modeltest.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'tests') diff --git a/tests/client/modeltest.cpp b/tests/client/modeltest.cpp index bc5d95e..8be92a6 100644 --- a/tests/client/modeltest.cpp +++ b/tests/client/modeltest.cpp @@ -260,21 +260,6 @@ private Q_SLOTS: delete model; } - - /* - * Test if the model is clearead after GMenuModel be destroyed - */ - void testDestroyGMenuModel() - { - GMenu *menu = g_menu_new(); - g_menu_append(menu, "test-menu0", NULL); - g_menu_append(menu, "test-menu1", NULL); - TestMenuModel model(reinterpret_cast(menu)); - QCOMPARE(model.rowCount(), 2); - - g_object_unref(menu); - QCOMPARE(model.rowCount(), 0); - } }; QTEST_MAIN(ModelTest) -- cgit v1.2.3