Raise a error when try to modify a read-only property.
Add get function as mandatory in QProperty constructor.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
1162a844bd
commit
6bd528978c
3 changed files with 22 additions and 6 deletions
|
|
@ -143,11 +143,11 @@ int qproperty_init(PyObject* self, PyObject* args, PyObject* kwds)
|
|||
"designable", "scriptable", "stored", "user",
|
||||
"constant", "final", 0};
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds,
|
||||
"O|OOOOsbbbbbb:QtCore.QProperty", (char**) kwlist,
|
||||
/*O*/&type,
|
||||
/*OOOO*/ &(data->fget), &(data->fset), &(data->freset), &(data->fdel),
|
||||
/*s*/&(data->doc),
|
||||
/*bbbbbb*/&(data->designable), &(data->scriptable), &(data->stored), &(data->user), &(data->constant), &(data->final)))
|
||||
"OO|OOOsbbbbbb:QtCore.QProperty", (char**) kwlist,
|
||||
/*OO*/ &type, &(data->fget),
|
||||
/*OOOO*/ &(data->fset), &(data->freset), &(data->fdel),
|
||||
/*s*/ &(data->doc),
|
||||
/*bbbbbb*/ &(data->designable), &(data->scriptable), &(data->stored), &(data->user), &(data->constant), &(data->final)))
|
||||
return 0;
|
||||
|
||||
if (!data->fset && data->fget)
|
||||
|
|
@ -187,6 +187,8 @@ int qproperty_set(PyObject* self, PyObject* source, PyObject* value)
|
|||
Py_INCREF(value);
|
||||
Shiboken::AutoDecRef result(PyObject_CallObject(data->fset, args));
|
||||
return (result.isNull() ? -1 : 0);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_AttributeError, "Attibute read only");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue