[pygtk] Patches for GdkWindow, GdkStyle attributes

John Ehresman jpe@archaeopteryx.com
Thu, 28 Sep 2000 18:57:31 -0400 (EDT)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

---1463786495-1635826752-970181851=:1734
Content-Type: TEXT/PLAIN; charset=US-ASCII


Hi,

Attached is a patch against the 0.6.5 release that fixes a number of core
dumps when attributes of a GdkStyle or GdkWindow object are accessed.  It
adds checks for NULL pointers and returns None in those cases.  It also
restricts the available attributes on a pixmap GdkWindow to depth, height,
type, & width -- accessing these attributes triggers errors at the Xlib
level.

I can update these patches to be either against 0.6.6 or the CVS sources
if that would help them get applied to future pygtk versions.

Thanks,

John
 
------------------------------------------------------------------------
Archaeopteryx Software, Inc.                        Wing IDE for Python 
www.archaeopteryx.com                               Take Flight!


---1463786495-1635826752-970181851=:1734
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="pygtk.diff"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.10.10009281857310.1734@egret>
Content-Description: 
Content-Disposition: attachment; filename="pygtk.diff"

LS0tIC9ob21lL2pwZS9kb3duL3B5Z3RrLTAuNi41L2d0a21vZHVsZS5jCU1v
biBNYXIgMTMgMDQ6MDQ6MTQgMjAwMA0KKysrIGd0a21vZHVsZS5jCVR1ZSBT
ZXAgMjYgMTc6NDI6MzAgMjAwMA0KQEAgLTYzNywxMCArNjQzLDE4IEBADQog
ICAgIHJldHVybiBQeUd0a1N0eWxlSGVscGVyX05ldyhzdHlsZSwgU1RZTEVf
R0NfQVJSQVksIHN0eWxlLT50ZXh0X2djKTsNCiAgIGlmICghc3RyY21wKGF0
dHIsICJiYXNlX2djIikpDQogICAgIHJldHVybiBQeUd0a1N0eWxlSGVscGVy
X05ldyhzdHlsZSwgU1RZTEVfR0NfQVJSQVksIHN0eWxlLT5iYXNlX2djKTsN
Ci0gIGlmICghc3RyY21wKGF0dHIsICJibGFja19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Il9fbWVtYmVy
c19fIikpDQorICAgICAgcmV0dXJuIFB5X0J1aWxkVmFsdWUoIltzc3Nzc3Nz
c3Nzc3NzXSIsICJjaGlsZHJlbiIsICJjb2xvcm1hcCIsICJkZXB0aCIsDQor
ICAgICAgICAgICAgICAgICAgICAgICAgICAgImhlaWdodCIsICJwYXJlbnQi
LCAicG9pbnRlciIsICJwb2ludGVyX3N0YXRlIiwNCisgICAgICAgICAgICAg
ICAgICAgICAgICAgICAidG9wbGV2ZWwiLCAidHlwZSIsICJ3aWR0aCIsICJ4
IiwgInhpZCIsICJ5Iik7DQorICAgIGlmICghc3RyY21wKGtleSwgIndpZHRo
IikpIHsNCisgICAgICBnZGtfd2luZG93X2dldF9zaXplKHdpbiwgJngsIE5V
TEwpOw0KKyAgICAgIHJldHVybiBQeUludF9Gcm9tTG9uZyh4KTsNCisgICAg
fQ0KKyAgICBpZiAoIXN0cmNtcChrZXksICJoZWlnaHQiKSkgew0KKyAgICAg
IGdka193aW5kb3dfZ2V0X3NpemUod2luLCBOVUxMLCAmeSk7DQorICAgICAg
cmV0dXJuIFB5SW50X0Zyb21Mb25nKHkpOw0KKyAgICB9DQorICAgIGlmICgh
c3RyY21wKGtleSwgIngiKSkgew0KKyAgICAgIGdka193aW5kb3dfZ2V0X3Bv
c2l0aW9uKHdpbiwgJngsIE5VTEwpOw0KKyAgICAgIHJldHVybiBQeUludF9G
cm9tTG9uZyh4KTsNCisgICAgfQ0KKyAgICBpZiAoIXN0cmNtcChrZXksICJ5
IikpIHsNCisgICAgICBnZGtfd2luZG93X2dldF9wb3NpdGlvbih3aW4sIE5V
TEwsICZ5KTsNCisgICAgICByZXR1cm4gUHlJbnRfRnJvbUxvbmcoeSk7DQor
ICAgIH0NCisgICAgaWYgKCFzdHJjbXAoa2V5LCAiY29sb3JtYXAiKSkgew0K
KyAgICAgIGlmIChnZGtfd2luZG93X2dldF90eXBlKHdpbikgPT0gR0RLX1dJ
TkRPV19QSVhNQVApIHsNCisgICAgIC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