aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-09-16 19:12:33 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:05:59 -0300
commit3ce6cdd1b6868ae8494c0a89bef4db85988758b4 (patch)
tree2a03ff126c94a2116babf1993fbb6b649ef22741 /tests
parentca1a485e51c1afae531776ffe61968da68461dcf (diff)
Fix bug#339 - "RuntimeError when accessing mousepress event object"
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Lauro Moura <lauro.filho@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/objecttype.cpp6
-rw-r--r--tests/libsample/objecttype.h4
-rw-r--r--tests/samplebinding/ownership_invalidate_after_use_test.py21
-rw-r--r--tests/samplebinding/typesystem_sample.xml3
4 files changed, 33 insertions, 1 deletions
diff --git a/tests/libsample/objecttype.cpp b/tests/libsample/objecttype.cpp
index ea3c78e7c..c1407d237 100644
--- a/tests/libsample/objecttype.cpp
+++ b/tests/libsample/objecttype.cpp
@@ -167,6 +167,12 @@ ObjectType::processEvent(ObjectTypeList objects, Event *event)
}
void
+ObjectType::callInvalidateEvent(Event* event)
+{
+ invalidateEvent(event);
+}
+
+void
ObjectType::setLayout(ObjectTypeLayout* l)
{
if (!l) {
diff --git a/tests/libsample/objecttype.h b/tests/libsample/objecttype.h
index c3bd8c626..b09b402e7 100644
--- a/tests/libsample/objecttype.h
+++ b/tests/libsample/objecttype.h
@@ -78,6 +78,9 @@ public:
virtual bool event(Event* event);
static int processEvent(ObjectTypeList objects, Event *event);
+ void callInvalidateEvent(Event* event);
+ virtual void invalidateEvent(Event* event) {}
+
// This nonsense method emulate QWidget.setLayout method
// All layout objects will became children of this object.
void setLayout(ObjectTypeLayout* layout);
@@ -99,7 +102,6 @@ public:
void setObject(const Null&);
int callId() const;
-
private:
ObjectType(const ObjectType&);
ObjectType& operator=(const ObjectType&);
diff --git a/tests/samplebinding/ownership_invalidate_after_use_test.py b/tests/samplebinding/ownership_invalidate_after_use_test.py
index 80f252d51..5a03fc470 100644
--- a/tests/samplebinding/ownership_invalidate_after_use_test.py
+++ b/tests/samplebinding/ownership_invalidate_after_use_test.py
@@ -42,6 +42,22 @@ class ExtObjectType(ObjectType):
self.type_of_last_event = event.eventType()
return True
+class MyObjectType (ObjectType):
+ def __init__(self):
+ super(MyObjectType, self).__init__()
+ self.fail = False
+
+ def event(self, ev):
+ self.callInvalidateEvent(ev)
+ try:
+ ev.eventType()
+ except:
+ self.fail = True
+ raise
+ return True
+
+ def invalidateEvent(self, ev):
+ pass
class OwnershipInvalidateAfterUseTest(unittest.TestCase):
'''Ownership tests for cases of invalidation of Python wrapper after use.'''
@@ -61,6 +77,11 @@ class OwnershipInvalidateAfterUseTest(unittest.TestCase):
self.assertEqual(eot.type_of_last_event, Event.ANY_EVENT)
self.assertRaises(RuntimeError, ot.event, eot.last_event)
+ def testit(self):
+ obj = MyObjectType()
+ obj.causeEvent(Event.BASIC_EVENT)
+ self.assertFalse(obj.fail)
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index de262c9ee..40b70ab40 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -141,6 +141,9 @@
<modify-function signature="event(Event*)">
<modify-argument index="1" invalidate-after-use="yes"/>
</modify-function>
+ <modify-function signature="invalidateEvent(Event*)">
+ <modify-argument index="1" invalidate-after-use="yes"/>
+ </modify-function>
<modify-function signature="create()">
<modify-argument index="return">
<define-ownership owner="target"/>