GNOME Bugzilla – Bug 79191
gdk_window_set_back_pixmap call can generate BadMatch X Window System error.
Last modified: 2004-12-22 21:47:04 UTC
In gdk/x11/gdkwindow-x11.c (gdk_window_set_back_pixmap), if the pixmap's depth does not match with the window depth a BadMatch X Window System error results.
Attaching a patch which fixes this. The patch does the following. 1. If the pixmap depth matches the window depth then we go ahead and set the background pixmap for the window. 2. Else we do not set the background pixmap for the window.
Created attachment 7799 [details] [review] proposed patch
This bug is also related to bug #78061
If we applied sommething like this, it would only be as a debugging aid. Calling this function with mismatched depths is not allowed.
i think that this was fixed as a part of the nautilus bug (78061). We ourselves are not aware of any applications which calls this function with different depths but if we can put up the check atleast it will not have crashes that we have seen with nautilus.
I still feel the check is needed. If we know something is going to fail, we have to put a check for that, although we know the function should not be called with those invalid parameters. The reasoning is the same as the check made for the window passed being NULL or not. Bharat: The nautilus bug (78096) which was fixed, used to call XSetWindowBackgroundPixmap() explicitly and that why the problem. It never used to call gdk_window_set_back_pixmap(). The function that will cause a problem is nautilus/libnautilus- private/nautilus-directory-background.c where we call gdk_window_set_back_pixmap(). I guess a separate bug can be filed under nautilus for this. However to prevent such errors the check has to be made in gdk too.
I've comitted something along these lines. (To HEAD, not stable, since isn't a bug fix.) (Note that the sense of the comparison in your patch is backwards: g_return_if_fail (a != b) is essentially same as: g_assert (a != b) It's an assertion that "a != b".) But hopefully it's clear that this does not make any code work that didn't previously work ... it's just a debugging aid. Tue May 14 15:40:49 2002 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkwindow-{linux-fb,win32,x11.c} (gdk_window_set_back_pixmap): Add a sanity g_return_if_fail() check for the depths for the window and pixmap. (#79191, Shivaram Upadhyayula)
Oops. I got it wrong there :-). Thanks Owen..