Fix bug 1016 - "Calling of Q_INVOKABLE method returning not QVariant is impossible..."

This commit is contained in:
Hugo Parente Lima 2011-10-26 18:28:51 -02:00
commit 15ceed791f
7 changed files with 163 additions and 18 deletions

View file

@ -12,11 +12,13 @@ add_definitions(-DRXX_ALLOCATOR_INIT_0)
set(pysidetest_SRC
testobject.cpp
testview.cpp
hiddenobject.cpp
)
set(pysidetest_MOC_HEADERS
testobject.h
testview.h
hiddenobject.h
)
qt4_wrap_cpp(pysidetest_MOC_SRC ${pysidetest_MOC_HEADERS})
@ -86,3 +88,4 @@ PYSIDE_TEST(signalwithdefaultvalue_test.py)
PYSIDE_TEST(signalemissionfrompython_test.py)
PYSIDE_TEST(version_test.py)
PYSIDE_TEST(typedef_signal_test.py)
PYSIDE_TEST(bug_1016.py)

View file

@ -0,0 +1,12 @@
from testbinding import *
import unittest
class TestBug1016 (unittest.TestCase):
def testIt(self):
obj = getHiddenObject()
self.assertEqual(obj.callMe(), None)
self.assertTrue(obj.wasCalled())
if __name__ == "__main__":
unittest.main()

View file

@ -0,0 +1,38 @@
/*
* This file is part of the PySide project.
*
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: PySide team <contact@pyside.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "hiddenobject.h"
void HiddenObject::callMe()
{
m_called = true;
}
bool HiddenObject::wasCalled()
{
return m_called;
}
QObject* getHiddenObject()
{
return new HiddenObject();
}

View file

@ -0,0 +1,49 @@
/*
* This file is part of the PySide project.
*
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: PySide team <contact@pyside.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HIDDENOBJECT_H
#define HIDDENOBJECT_H
#ifdef pysidetest_EXPORTS
#define PYSIDE_EXPORTS 1
#endif
#include "pysidemacros.h"
#include <QObject>
// This class shouldn't be exported!
class HiddenObject : public QObject
{
Q_OBJECT
public:
HiddenObject() : m_called(false) {}
Q_INVOKABLE void callMe();
public slots:
bool wasCalled();
private:
bool m_called;
};
// Return a instance of HiddenObject
PYSIDE_API QObject* getHiddenObject();
#endif

View file

@ -1,3 +1,6 @@
#include <pyside_global.h>
// PySide global.h file
#include "pyside_global.h"
#include "testobject.h"
#include "testview.h"
#define PYSIDE_API
#include "hiddenobject.h"

View file

@ -6,6 +6,8 @@
<primitive-type name="TypedefValue"/>
<object-type name="TestObject" />
<function signature="getHiddenObject()" />
<inject-code position="end">
Shiboken::TypeResolver::createObjectTypeResolver&lt; ::PySideCPP2::TestObjectWithoutNamespace>("TestObjectWithoutNamespace*");
Shiboken::TypeResolver::createValueTypeResolver&lt; ::PySideCPP2::PySideLong>("PySideLong");