summaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-21 18:08:46 -0300
committerRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-22 10:43:01 -0300
commite12197e2822a8cca0022d0843057548246930c16 (patch)
treed20410a30e1f82b9ff5976bff1a6ef685d84eb1b /libpyside
parent3bc0d023c848be0d8e7e7337a92980647e11804a (diff)
downloadpyside-e12197e2822a8cca0022d0843057548246930c16.tar.gz
pyside-e12197e2822a8cca0022d0843057548246930c16.tar.xz
pyside-e12197e2822a8cca0022d0843057548246930c16.zip
Fix generated property flags on metaobject.
Fixes bug #478 Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/dynamicqmetaobject.cpp47
-rw-r--r--libpyside/dynamicqmetaobject_p.h6
-rw-r--r--libpyside/pysideproperty.cpp13
3 files changed, 37 insertions, 29 deletions
diff --git a/libpyside/dynamicqmetaobject.cpp b/libpyside/dynamicqmetaobject.cpp
index 14fbe86..43aeae6 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 d271752..e692700 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/pysideproperty.cpp b/libpyside/pysideproperty.cpp
index 51f848d..72b718c 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;
}