aboutsummaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/dynamicqmetaobject.cpp47
-rw-r--r--libpyside/dynamicqmetaobject_p.h6
-rw-r--r--libpyside/globalreceiver.cpp9
-rw-r--r--libpyside/pyside.cpp11
-rw-r--r--libpyside/pysideproperty.cpp13
5 files changed, 53 insertions, 33 deletions
diff --git a/libpyside/dynamicqmetaobject.cpp b/libpyside/dynamicqmetaobject.cpp
index 14fbe864e..43aeae66d 100644
--- a/libpyside/dynamicqmetaobject.cpp
+++ b/libpyside/dynamicqmetaobject.cpp
@@ -132,7 +132,6 @@ static bool isQRealType(const char *type)
}
-
/*
* Avoid API break keep this on cpp
*/
@@ -164,25 +163,31 @@ uint PropertyData::flags() const
if (PySide::Property::hasReset(m_data))
flags |= Resettable;
- if (!PySide::Property::isDesignable(m_data))
- flags |= ResolveDesignable;
- else
+ if (PySide::Property::isDesignable(m_data))
flags |= Designable;
-
- if (!PySide::Property::isScriptable(m_data))
- flags |= ResolveScriptable;
else
- flags |= Scriptable;
+ flags |= ResolveDesignable;
- if (!PySide::Property::isStored(m_data))
- flags |= ResolveStored;
+ if (PySide::Property::isScriptable(m_data))
+ flags |= Scriptable;
else
- flags |= Stored;
+ flags |= ResolveScriptable;
- if (!PySide::Property::isUser(m_data))
- flags |= ResolveUser;
+ if (PySide::Property::isStored(m_data))
+ flags |= Stored;
else
+ flags |= ResolveStored;
+
+ //EDITABLE
+ flags |= ResolveEditable;
+
+ if (PySide::Property::isUser(m_data))
flags |= User;
+ else
+ flags |= ResolveUser;
+
+ if (m_notifyId != -1)
+ flags |= Notify;
if (PySide::Property::isConstant(m_data))
flags |= Constant;
@@ -190,9 +195,6 @@ uint PropertyData::flags() const
if (PySide::Property::isFinal(m_data))
flags |= Final;
- if (m_notifyId)
- flags |= Notify;
-
return flags;
}
@@ -247,7 +249,7 @@ PropertyData::PropertyData()
{
}
-PropertyData::PropertyData(const char* name, uint notifyId, PySideProperty* data)
+PropertyData::PropertyData(const char* name, int notifyId, PySideProperty* data)
: m_name(name), m_notifyId(notifyId), m_data(data)
{
}
@@ -268,7 +270,7 @@ QByteArray PropertyData::name() const
return m_name;
}
-uint PropertyData::notifyId() const
+int PropertyData::notifyId() const
{
return m_notifyId;
}
@@ -370,10 +372,10 @@ void DynamicQMetaObject::addProperty(const char* propertyName, PyObject* data)
// retrieve notifyId
PySideProperty* property = reinterpret_cast<PySideProperty*>(data);
const char* signalNotify = PySide::Property::getNotifyName(property);
- uint notifyId = 0;
+ int notifyId = -1;
if (signalNotify) {
QByteArray signalSignature(signalNotify);
- notifyId = m_d->m_signals.indexOf(signalNotify) + 1;
+ notifyId = m_d->m_signals.indexOf(signalNotify);
}
//search for a empty space
@@ -553,9 +555,8 @@ void DynamicQMetaObject::DynamicQMetaObjectPrivate::updateMetaObject(QMetaObject
}
//write properties notify
- foreach(PropertyData pp, m_properties) {
- data[index++] = pp.notifyId(); //signal notify index
- }
+ foreach(PropertyData pp, m_properties)
+ data[index++] = pp.notifyId() >= 0 ? pp.notifyId() : 0; //signal notify index
data[index++] = 0; // the end
diff --git a/libpyside/dynamicqmetaobject_p.h b/libpyside/dynamicqmetaobject_p.h
index d2717524e..e69270041 100644
--- a/libpyside/dynamicqmetaobject_p.h
+++ b/libpyside/dynamicqmetaobject_p.h
@@ -54,18 +54,18 @@ namespace PySide
{
public:
PropertyData();
- PropertyData(const char* name, uint notifyId=0, PySideProperty* data = 0);
+ PropertyData(const char* name, int notifyId=0, PySideProperty* data = 0);
QByteArray name() const;
QByteArray type() const;
uint flags() const;
bool isValid() const;
- uint notifyId() const;
+ int notifyId() const;
bool operator==(const PropertyData& other) const;
bool operator==(const char* name) const;
private:
QByteArray m_name;
- uint m_notifyId;
+ int m_notifyId;
PySideProperty* m_data;
};
}
diff --git a/libpyside/globalreceiver.cpp b/libpyside/globalreceiver.cpp
index 2c126044e..d63ebdf66 100644
--- a/libpyside/globalreceiver.cpp
+++ b/libpyside/globalreceiver.cpp
@@ -116,7 +116,8 @@ GlobalReceiver::GlobalReceiver()
GlobalReceiver::~GlobalReceiver()
{
- foreach(DynamicSlotData* data, m_slotReceivers) {
+ while(!m_slotReceivers.empty()) {
+ DynamicSlotData* data = m_slotReceivers.take(m_slotReceivers.begin().key());
data->clear();
delete data;
}
@@ -203,8 +204,10 @@ int GlobalReceiver::qt_metacall(QMetaObject::Call call, int id, void** args)
if (strcmp(slot.signature(), RECEIVER_DESTROYED_SLOT_NAME) == 0) {
QObject *arg = *(QObject**)args[1];
- QHash<int, DynamicSlotData*>::iterator i = m_slotReceivers.begin();
- while(i != m_slotReceivers.end()) {
+ //avoid hash changes during the destruction
+ QHash<int, DynamicSlotData*> copy = m_slotReceivers;
+ QHash<int, DynamicSlotData*>::iterator i = copy.begin();
+ while(i != copy.end()) {
if (i.value()->hasRefTo(arg)) {
disconnectNotify(arg, i.key());
break;
diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp
index 2e2f57428..bbec1fa63 100644
--- a/libpyside/pyside.cpp
+++ b/libpyside/pyside.cpp
@@ -114,12 +114,21 @@ void destroyQCoreApplication()
PyTypeObject* pyQObjectType = Shiboken::TypeResolver::get("QObject*")->pythonType();
assert(pyQObjectType);
+ QList<SbkObject*> objects;
+
+ //filter only QObjects which we have ownership, this will avoid list changes during the destruction of some parent object
foreach (SbkObject* pyObj, bm.getAllPyObjects()) {
if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) {
if (Shiboken::Object::hasOwnership(pyObj))
- Shiboken::callCppDestructor<QObject>(Shiboken::Object::cppPointer(pyObj, Shiboken::SbkType<QObject*>()));
+ objects << pyObj;
}
}
+
+ //Now we can destroy all object in the list
+ foreach (SbkObject* pyObj, objects)
+ Shiboken::callCppDestructor<QObject>(Shiboken::Object::cppPointer(pyObj, Shiboken::SbkType<QObject*>()));
+
+ // in the end destroy app
delete app;
}
diff --git a/libpyside/pysideproperty.cpp b/libpyside/pysideproperty.cpp
index 51f848d67..72b718c58 100644
--- a/libpyside/pysideproperty.cpp
+++ b/libpyside/pysideproperty.cpp
@@ -117,6 +117,7 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds)
pData->fget = 0;
pData->freset = 0;
pData->fdel = 0;
+ pData->final = 0;
pData->designable = true;
pData->scriptable = true;
pData->stored = true;
@@ -124,6 +125,7 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds)
pData->doc = 0;
pData->notify = 0;
pData->notifySignature = 0;
+ pData->constant = 0;
static const char *kwlist[] = {"type", "fget", "fset", "freset", "fdel", "doc", "notify",
"designable", "scriptable", "stored", "user",
@@ -134,12 +136,17 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds)
/*OOO*/ &(pData->fset), &(pData->freset), &(pData->fdel),
/*s*/ &(pData->doc),
/*O*/ &(pData->notify),
- /*bbbbbb*/ &(pData->designable), &(pData->scriptable), &(pData->stored), &(pData->user), &(pData->constant), &(pData->final)))
+ /*bbbbbb*/ &(pData->designable), &(pData->scriptable), &(pData->stored), &(pData->user), &(pData->constant), &(pData->final))) {
+ free(pData);
return 0;
+ }
- if (!pData->fset && pData->fget)
- pData->constant = true;
+ if (pData->constant && (pData->fset || pData->notify)) {
+ free(pData);
+ PyErr_SetString(PyExc_AttributeError, "A constant property cannot have a WRITE method or a NOTIFY signal.");
+ return 0;
+ }
pData->typeName = PySide::Signal::getTypeName(type);
return 1;
}