Fix bug#316 - "QAbstractItemModel.createIndex is broken"
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Renato Araújo <renato.filho@openbossa.org>
This commit is contained in:
parent
e0a5ca517f
commit
5c0d39b9dc
4 changed files with 26 additions and 4 deletions
|
|
@ -2,11 +2,11 @@ static bool getReceiver(PyObject *callback, QObject **receiver, PyObject **self)
|
||||||
{
|
{
|
||||||
if (PyMethod_Check(callback)) {
|
if (PyMethod_Check(callback)) {
|
||||||
*self = PyMethod_GET_SELF(callback);
|
*self = PyMethod_GET_SELF(callback);
|
||||||
if (SbkQObject_Check(*self))
|
if (Shiboken::Converter<QObject*>::checkType(*self))
|
||||||
*receiver = Converter<QObject*>::toCpp(*self);
|
*receiver = Converter<QObject*>::toCpp(*self);
|
||||||
} else if (PyCFunction_Check(callback)) {
|
} else if (PyCFunction_Check(callback)) {
|
||||||
*self = PyCFunction_GET_SELF(callback);
|
*self = PyCFunction_GET_SELF(callback);
|
||||||
if (*self && SbkQObject_Check(*self))
|
if (*self && Shiboken::Converter<QObject*>::checkType(*self))
|
||||||
*receiver = Converter<QObject*>::toCpp(*self);
|
*receiver = Converter<QObject*>::toCpp(*self);
|
||||||
} else if (PyCallable_Check(callback)) {
|
} else if (PyCallable_Check(callback)) {
|
||||||
// Ok, just a callable object
|
// Ok, just a callable object
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ struct Converter<QString>
|
||||||
{
|
{
|
||||||
return PyString_Check(pyObj)
|
return PyString_Check(pyObj)
|
||||||
|| PyUnicode_Check(pyObj)
|
|| PyUnicode_Check(pyObj)
|
||||||
|| SbkQByteArray_Check(pyObj)
|
|| Converter<QByteArray>::checkType(pyObj)
|
||||||
|| pyObj == Py_None
|
|| pyObj == Py_None
|
||||||
#if PY_VERSION_HEX < 0x03000000
|
#if PY_VERSION_HEX < 0x03000000
|
||||||
|| (pyObj->ob_type->tp_as_buffer
|
|| (pyObj->ob_type->tp_as_buffer
|
||||||
|
|
@ -42,7 +42,7 @@ struct Converter<QString>
|
||||||
return QString(Converter< char * >::toCpp(pyObj));
|
return QString(Converter< char * >::toCpp(pyObj));
|
||||||
} else if (pyObj == Py_None) {
|
} else if (pyObj == Py_None) {
|
||||||
return QString();
|
return QString();
|
||||||
} else if (SbkQByteArray_Check(pyObj)) {
|
} else if (Converter<QByteArray>::checkType(pyObj)) {
|
||||||
return QString(Converter< QByteArray >::toCpp(pyObj));
|
return QString(Converter< QByteArray >::toCpp(pyObj));
|
||||||
}
|
}
|
||||||
#if PY_VERSION_HEX < 0x03000000
|
#if PY_VERSION_HEX < 0x03000000
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ PYSIDE_TEST(duck_punching_test.py)
|
||||||
PYSIDE_TEST(hash_test.py)
|
PYSIDE_TEST(hash_test.py)
|
||||||
PYSIDE_TEST(missing_symbols_test.py)
|
PYSIDE_TEST(missing_symbols_test.py)
|
||||||
PYSIDE_TEST(qabs_test.py)
|
PYSIDE_TEST(qabs_test.py)
|
||||||
|
PYSIDE_TEST(qabstractitemmodel_test.py)
|
||||||
PYSIDE_TEST(qabstracttransition_test.py)
|
PYSIDE_TEST(qabstracttransition_test.py)
|
||||||
PYSIDE_TEST(qanimationgroup_test.py)
|
PYSIDE_TEST(qanimationgroup_test.py)
|
||||||
PYSIDE_TEST(qbitarray_test.py)
|
PYSIDE_TEST(qbitarray_test.py)
|
||||||
|
|
|
||||||
21
tests/QtCore/qabstractitemmodel_test.py
Normal file
21
tests/QtCore/qabstractitemmodel_test.py
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from PySide.QtCore import *
|
||||||
|
|
||||||
|
class MyModel (QAbstractListModel):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Foo:
|
||||||
|
pass
|
||||||
|
|
||||||
|
class TestQModelIndexInternalPointer(unittest.TestCase):
|
||||||
|
|
||||||
|
def testInternalPointer(self):
|
||||||
|
m = MyModel()
|
||||||
|
foo = Foo()
|
||||||
|
idx = m.createIndex(0,0, foo)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue