gimp r25958 - in branches/soc-2008-python: . plug-ins/pygimp
- From: larsc svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25958 - in branches/soc-2008-python: . plug-ins/pygimp
- Date: Sun, 15 Jun 2008 14:23:33 +0000 (UTC)
Author: larsc
Date: Sun Jun 15 14:23:33 2008
New Revision: 25958
URL: http://svn.gnome.org/viewvc/gimp?rev=25958&view=rev
Log:
2008-06-15 Lars-Peter Clausen <lars metafoo de>
* plug-ins/pygimp/pygimp-image.c:
* plug-ins/pygimp/pygimp-drawable.c:
* plug-ins/pygimp/pygimp-vectors.c:
Added checks to (pygimp_{image,drawable,layer,channel,vectores}_new) to
ensure that a python object only gets created when the object id is
valid, otherwise return None.
* plug-ins/pygimp/pygimp-display:
(disp_repr): Changed repr string to match the rest of pygimp.
(pygimp_display_new): Check if a display id is valid.
Modified:
branches/soc-2008-python/ChangeLog
branches/soc-2008-python/plug-ins/pygimp/pygimp-display.c
branches/soc-2008-python/plug-ins/pygimp/pygimp-drawable.c
branches/soc-2008-python/plug-ins/pygimp/pygimp-image.c
branches/soc-2008-python/plug-ins/pygimp/pygimp-vectors.c
Modified: branches/soc-2008-python/plug-ins/pygimp/pygimp-display.c
==============================================================================
--- branches/soc-2008-python/plug-ins/pygimp/pygimp-display.c (original)
+++ branches/soc-2008-python/plug-ins/pygimp/pygimp-display.c Sun Jun 15 14:23:33 2008
@@ -46,7 +46,7 @@
{
PyGimpDisplay *self;
- if (ID == -1) {
+ if (!gimp_display_is_valid(ID)) {
Py_INCREF(Py_None);
return Py_None;
}
@@ -72,7 +72,7 @@
{
PyObject *s;
- s = PyString_FromString("<display>");
+ s = PyString_FromString("<gimp.Display>");
return s;
}
Modified: branches/soc-2008-python/plug-ins/pygimp/pygimp-drawable.c
==============================================================================
--- branches/soc-2008-python/plug-ins/pygimp/pygimp-drawable.c (original)
+++ branches/soc-2008-python/plug-ins/pygimp/pygimp-drawable.c Sun Jun 15 14:23:33 2008
@@ -1202,7 +1202,10 @@
{
PyObject *self;
- if (drawable == NULL && ID == -1) {
+ if (drawable != NULL)
+ ID = drawable->drawable_id;
+
+ if (!gimp_drawable_is_valid(ID)) {
Py_INCREF(Py_None);
return Py_None;
}
@@ -1211,12 +1214,7 @@
ID = drawable->drawable_id;
/* create the appropriate object type */
-
- /* avoids calling gimp_drawable_is_layer with an invalid id
- * pygimp_channel_new handles it cleanly
- */
- if (gimp_drawable_is_valid(ID) &&
- gimp_drawable_is_layer(ID))
+ if (gimp_drawable_is_layer(ID))
self = pygimp_layer_new(ID);
else
self = pygimp_channel_new(ID);
@@ -1224,6 +1222,7 @@
if (self == NULL)
return NULL;
+ if (PyObject_TypeCheck(self, &PyGimpDrawable_Type))
((PyGimpDrawable *)self)->drawable = drawable;
return self;
@@ -1692,7 +1691,7 @@
gchar *name;
name = gimp_drawable_get_name(self->ID);
- s = PyString_FromFormat("<gimp.Layer '%s'>", name);
+ s = PyString_FromFormat("<gimp.Layer '%s'>", name ? name : "(null)");
g_free(name);
return s;
@@ -1778,7 +1777,7 @@
{
PyGimpLayer *self;
- if (ID == -1) {
+ if (!gimp_drawable_is_valid(ID) || !gimp_drawable_is_layer(ID)) {
Py_INCREF(Py_None);
return Py_None;
}
@@ -1971,7 +1970,7 @@
gchar *name;
name = gimp_drawable_get_name(self->ID);
- s = PyString_FromFormat("<gimp.Channel '%s'>", name);
+ s = PyString_FromFormat("<gimp.Channel '%s'>", name ? name : "(null)");
g_free(name);
return s;
@@ -2066,7 +2065,7 @@
{
PyGimpChannel *self;
- if (ID == -1) {
+ if (!gimp_drawable_is_valid(ID) || !gimp_drawable_is_channel(ID)) {
Py_INCREF(Py_None);
return Py_None;
}
Modified: branches/soc-2008-python/plug-ins/pygimp/pygimp-image.c
==============================================================================
--- branches/soc-2008-python/plug-ins/pygimp/pygimp-image.c (original)
+++ branches/soc-2008-python/plug-ins/pygimp/pygimp-image.c Sun Jun 15 14:23:33 2008
@@ -1314,7 +1314,7 @@
{
PyGimpImage *self;
- if (ID == -1) {
+ if (!gimp_image_is_valid(ID)) {
Py_INCREF(Py_None);
return Py_None;
}
Modified: branches/soc-2008-python/plug-ins/pygimp/pygimp-vectors.c
==============================================================================
--- branches/soc-2008-python/plug-ins/pygimp/pygimp-vectors.c (original)
+++ branches/soc-2008-python/plug-ins/pygimp/pygimp-vectors.c Sun Jun 15 14:23:33 2008
@@ -981,7 +981,7 @@
{
PyGimpVectors *self;
- if (ID == -1) {
+ if (!gimp_vectors_is_valid(ID)) {
Py_INCREF(Py_None);
return Py_None;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]