Skip to content
Snippets Groups Projects
Commit 31c22183 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Bug in item controller when widget is always hidden

parent 593e427f
No related branches found
No related tags found
No related merge requests found
...@@ -81,7 +81,9 @@ void SessionItemController::unsubscribe() ...@@ -81,7 +81,9 @@ void SessionItemController::unsubscribe()
if (!m_item) if (!m_item)
return; return;
unsubscribeParent(); if (m_parent_subscribed)
unsubscribeParent();
m_item->mapper()->unsubscribe(parent()); m_item->mapper()->unsubscribe(parent());
} }
......
...@@ -79,6 +79,7 @@ private slots: ...@@ -79,6 +79,7 @@ private slots:
void test_onItemDestroyWidgetVisible(); void test_onItemDestroyWidgetVisible();
void test_onItemDestroyWidgetHidden(); void test_onItemDestroyWidgetHidden();
void test_onTwoItems(); void test_onTwoItems();
void test_onTwoItemsWhenHidden();
void test_deleteWidget(); void test_deleteWidget();
}; };
...@@ -273,6 +274,39 @@ inline void TestSessionItemController::test_onTwoItems() ...@@ -273,6 +274,39 @@ inline void TestSessionItemController::test_onTwoItems()
QCOMPARE(listener.m_onPropertyChangeCount, 2); QCOMPARE(listener.m_onPropertyChangeCount, 2);
} }
//! Settings two items one after another, when widget stays hidden
inline void TestSessionItemController::test_onTwoItemsWhenHidden()
{
TestListener listener;
TestObject object(&listener);
SessionModel model("TestModel");
SessionItem* item1 = model.insertNewItem(Constants::BasicAxisType);
SessionItem* item2 = model.insertNewItem(Constants::BasicAxisType);
object.setVisible(false);
object.setItem(item1);
QCOMPARE(object.currentItem(), item1);
item1->setItemValue(BasicAxisItem::P_MAX, 4.0);
QCOMPARE(listener.m_onItemDestroyedCount, 0);
QCOMPARE(listener.m_onPropertyChangeCount, 0);
// changing the item
object.setItem(item2);
QCOMPARE(object.currentItem(), item2);
// changing the value of previous item, widget shouldn't react
item1->setItemValue(BasicAxisItem::P_MAX, 5.0);
QCOMPARE(listener.m_onItemDestroyedCount, 0);
QCOMPARE(listener.m_onPropertyChangeCount, 0);
// changing the value of new item, widget shouldn't react
item2->setItemValue(BasicAxisItem::P_MAX, 6.0);
QCOMPARE(listener.m_onPropertyChangeCount, 0);
}
//! Deleting the widget when item still alive. //! Deleting the widget when item still alive.
inline void TestSessionItemController::test_deleteWidget() inline void TestSessionItemController::test_deleteWidget()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment