summaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-12-01 18:09:09 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-12-02 18:12:24 -0200
commit59b4f2b59dcdee3831335c69109d3c19290d940f (patch)
tree13d38d407484874399e459fb261d0545c23789f3 /libpyside
parente20a97a480f2a3a6f1a4d7b186e1d1a4944647b7 (diff)
downloadpyside-59b4f2b59dcdee3831335c69109d3c19290d940f.tar.gz
pyside-59b4f2b59dcdee3831335c69109d3c19290d940f.tar.xz
pyside-59b4f2b59dcdee3831335c69109d3c19290d940f.zip
Fixed qt_metacall, now everything works as it should.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Lauro Moura <lauro.neto@openbossa.org>
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/pysidemetafunction.cpp21
-rw-r--r--libpyside/signalmanager.cpp30
-rw-r--r--libpyside/signalmanager.h1
3 files changed, 28 insertions, 24 deletions
diff --git a/libpyside/pysidemetafunction.cpp b/libpyside/pysidemetafunction.cpp
index bcccbb8..bee793c 100644
--- a/libpyside/pysidemetafunction.cpp
+++ b/libpyside/pysidemetafunction.cpp
@@ -98,29 +98,26 @@ void functionFree(void *self)
PyObject* functionCall(PyObject* self, PyObject* args, PyObject* kw)
{
+ static Shiboken::TypeResolver* typeResolver = Shiboken::TypeResolver::get("QVariant");
+ Q_ASSERT(typeResolver);
+
QGenericArgument gArgs[10];
+ QVariant vArgs[10];
PySideMetaFunction* function = reinterpret_cast<PySideMetaFunction*>(self);
- QList<QVariant*> vArgs;
QMetaMethod method = function->d->method;
- QList<QByteArray> pTypes = method.parameterTypes();
- int numArgs = pTypes.size();
+ int argsGiven = method.parameterTypes().size();
- Shiboken::TypeResolver* typeResolver = Shiboken::TypeResolver::get("QVariant");
- Q_ASSERT(typeResolver);
- for(int i=0; i < numArgs; i++) {
- QVariant *vArg;
+ for (int i = 0; i < argsGiven; ++i) {
Shiboken::AutoDecRef pyArg(PySequence_GetItem(args, i));
- typeResolver->toCpp(pyArg, (void**)&vArg, true);
- vArgs.append(vArg);
- gArgs[i] = Q_ARG(QVariant, *vArg);
+ gArgs[i] = Q_ARG(QVariant, vArgs[i]);
+ void* v[1] = { &vArgs[i] };
+ typeResolver->toCpp(pyArg, v);
}
QVariant retVariant;
QGenericReturnArgument returnValue = Q_RETURN_ARG(QVariant, retVariant);
method.invoke(function->d->qobject, returnValue, gArgs[0], gArgs[1], gArgs[2], gArgs[3], gArgs[4], gArgs[5], gArgs[6], gArgs[7], gArgs[8], gArgs[9]);
- while(!vArgs.isEmpty())
- delete vArgs.takeFirst();
if (retVariant.isValid())
return typeResolver->toPython(&retVariant);
diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp
index d4b0cb7..5ff62be 100644
--- a/libpyside/signalmanager.cpp
+++ b/libpyside/signalmanager.cpp
@@ -70,9 +70,17 @@ PyObjectWrapper::PyObjectWrapper(const PyObjectWrapper &other)
PyObjectWrapper::~PyObjectWrapper()
{
+ Shiboken::GilState gil;
Py_DECREF(m_me);
}
+PyObjectWrapper& PyObjectWrapper::operator=(const PySide::PyObjectWrapper& other)
+{
+ Py_INCREF(other.m_me);
+ Py_DECREF(m_me);
+ m_me = other.m_me;
+ return *this;
+}
PyObjectWrapper::operator PyObject*() const
{
@@ -179,24 +187,26 @@ static bool emitNormalSignal(QObject* source, int signalIndex, const char* signa
{
Shiboken::AutoDecRef sequence(PySequence_Fast(args, 0));
int argsGiven = PySequence_Fast_GET_SIZE(sequence.object());
+
if (argsGiven > argTypes.count()) {
PyErr_Format(PyExc_TypeError, "%s only accepts %d arguments, %d given!", signal, argTypes.count(), argsGiven);
return false;
}
- void** signalArgs = new void*[argsGiven+1];
- void** signalValues = new void*[argsGiven];
+ QVariant* signalValues = new QVariant[argsGiven];
+ void** signalArgs = new void*[argsGiven + 1];
signalArgs[0] = 0;
int i;
for (i = 0; i < argsGiven; ++i) {
- Shiboken::TypeResolver* typeResolver = Shiboken::TypeResolver::get(qPrintable(argTypes[i]));
+ const char* typeName = argTypes[i].toAscii().constData();
+ Shiboken::TypeResolver* typeResolver = Shiboken::TypeResolver::get(typeName);
if (typeResolver) {
- typeResolver->toCpp(PySequence_Fast_GET_ITEM(sequence.object(), i), &signalValues[i], true);
- if (Shiboken::TypeResolver::getType(qPrintable(argTypes[i])) == Shiboken::TypeResolver::ObjectType)
- signalArgs[i+1] = &signalValues[i];
- else
- signalArgs[i+1] = signalValues[i];
+ int typeId = QMetaType::type(typeName);
+ if (Shiboken::TypeResolver::getType(typeName) == Shiboken::TypeResolver::ValueType)
+ signalValues[i] = QVariant(typeId, (void*) 0);
+ signalArgs[i+1] = signalValues[i].data();
+ typeResolver->toCpp(PySequence_Fast_GET_ITEM(sequence.object(), i), &signalArgs[i+1]);
} else {
PyErr_Format(PyExc_TypeError, "Unknown type used to emit a signal: %s", qPrintable(argTypes[i]));
break;
@@ -207,10 +217,6 @@ static bool emitNormalSignal(QObject* source, int signalIndex, const char* signa
if (ok)
QMetaObject::activate(source, signalIndex, signalArgs);
- //cleanup memory
- for (int j = 0; j < i; ++j)
- Shiboken::TypeResolver::get(qPrintable(argTypes[j]))->deleteObject(signalArgs[j+1]);
-
delete[] signalArgs;
delete[] signalValues;
diff --git a/libpyside/signalmanager.h b/libpyside/signalmanager.h
index 91c86e0..f6ce1fb 100644
--- a/libpyside/signalmanager.h
+++ b/libpyside/signalmanager.h
@@ -43,6 +43,7 @@ public:
PyObjectWrapper(const PyObjectWrapper &other);
~PyObjectWrapper();
operator PyObject*() const;
+ PyObjectWrapper& operator=(const PyObjectWrapper &other);
private:
PyObject* m_me;
void* m_data; //future