LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-15-2010, 10:58 PM   #1
piccir
LQ Newbie
 
Registered: Mar 2010
Posts: 12

Rep: Reputation: 0
X Error of failed request: BadMatch


I'm working on a old piece of code on linux, after compiling without porblem at the execution I have this response:

src/xproject/xproject: Ok, a color display! :-)
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 78 (X_CreateColormap)
Serial number of failed request: 7
Current serial number in output stream: 15


looking at the source code I think the problem is related at the depth of my system 24 bit and the depth of this old piece of code 8 bit.
Unfortunately also I don't have experience in programming the XVideo and if someone can give me some help in programming the XVideo interface
Thank you

Piccir
 
Old 03-29-2010, 09:50 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
Without seeing any code it will be rather tough to help??
 
Old 03-29-2010, 11:33 PM   #3
piccir
LQ Newbie
 
Registered: Mar 2010
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by grail View Post
Without seeing any code it will be rather tough to help??
This is the part:

#ifdef X
static void projection_examine_visual(p)
Projection *p;
{
p->depth = DefaultDepth(p->display, p->screen);

if (p->depth < 8) {
/* It's monochrome display... to bad */
p->color_count = 0;
p->visual = DefaultVisual(p->display, p->screen);
p->colormap = DefaultColormap(p->display, p->screen);
p->black = BlackPixel(p->display, p->screen);
p->white = WhitePixel(p->display, p->screen);
info("Tough luck: monochrome...\n");
} else {
int i;
XColor *xcolor = (XColor *)alloca(256 * sizeof(XColor));

p->visual = DefaultVisual(p->display, p->screen);

/* Ok, try to allocate a 256 colors palette... */
p->color_count = 256;
p->colormap = XCreateColormap(p->display, p->parent, p->visual, AllocAll);
for (i = 0; i < p->color_count; i++) {
xcolor[i].pixel = i;
xcolor[i].red =
xcolor[i].green =
xcolor[i].blue =
(unsigned) i * 256;
xcolor[i].flags = DoRed | DoGreen | DoBlue;
}
XStoreColors(p->display, p->colormap, xcolor, p->color_count);
p->black = 0;
p->white = p->color_count - 1;
info("Ok, a color display! :-)\n");
}
}



For now I forced to use the bw mode, but in color mode doesn't work, always the same error

piccir
 
Old 03-30-2010, 04:43 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
Firstly, you found the QUOTE tags which is good, there are also CODE tags which will keep formatting and
make the code easier to read (above is very difficult)

Secondly, if I am reading the above correctly, your output:
Quote:
src/xproject/xproject: Ok, a color display! :-)
Says that it successfully got to the end of the code you have shown, ie
Code:
info("Ok, a color display! :-)\n")
This would lead me to think that whatever called:

Code:
static void projection_examine_visual(p)
Is where we need to see as the next line after this call would seem to be the issue
 
Old 04-02-2010, 10:05 AM   #5
piccir
LQ Newbie
 
Registered: Mar 2010
Posts: 12

Original Poster
Rep: Reputation: 0
I used gdb and I found where my program crash:

Quote:
531 projection_create_x_window(projection[0], display, screen, root);
532 projection_count = 1;
533
534 if (pgmfile) projection_set_background(projection[0], background[0]);
535 }
536
537 int main(argc, argv)
538 int argc;
539 char **argv;
540 {
and the function I think is projection_create_x_window

Quote:
void projection_create_x_window(p,dpy,scr,prnt)
Projection *p;
Display *dpy;
int scr;
Window prnt;
{
XSetWindowAttributes attributes;
long valuemask;
XSizeHints hints;

p->has_x_window = 1;

p->display = dpy;
p->screen = scr;
p->parent = prnt;

projection_examine_visual(p);

p->gc = DefaultGC(p->display, p->screen);
XSetBackground(p->display, p->gc, (ULONG) p->black);

attributes.event_mask = event_mask;
attributes.background_pixel = p->black;
attributes.colormap = p->colormap;
valuemask = CWEventMask | CWBackPixel | CWColormap;

p->window = XCreateWindow(p->display, p->parent, -1, -1,
(ULONG)p->width, (ULONG)p->height, 1, p->depth,
InputOutput, p->visual,
(ULONG)valuemask, &attributes);

hints.flags = PSize | PMinSize | PMaxSize;
hints.width = hints.min_width = hints.max_width = p->width;
hints.height = hints.min_height = hints.max_height = p->height;

XSetStandardProperties(p->display, p->window,
"Projection", "Projection",
None, NULL, 0, &hints);

p->pixmap = XCreatePixmap(p->display, p->window, (ULONG)p->width, (ULONG)p->height, (ULONG)p->depth);

if (p->background) {
int x = 0, y = 0, w, h, sx = 0, sy = 0;
p->background_pixmap = XCreatePixmap(p->display, p->window, (ULONG)p->width,
(ULONG)p->height, (ULONG)p->depth);
XSetForeground(p->display, p->gc, (ULONG)p->black);
XFillRectangle(p->display, p->background_pixmap, p->gc, 0, 0, (ULONG)p->width, (ULONG)p->height);
if (p->bg_x_ofs <= 0) sx = - p->bg_x_ofs;
else x = p->bg_x_ofs;
if (p->bg_y_ofs <= 0) sy = - p->bg_y_ofs;
else y = p->bg_y_ofs;
if (x + p->background->width - sx > p->width) w = p->width - x;
else w = p->background->width - sx;
if (y + p->background->height - sy > p->height) h = p->height - y;
else h = p->background->height - sy;
projection_x_put_image(p, p->background_pixmap, p->background, x, y, w, h, sx, sy);
}

XMapWindow(p->display, p->window);

projection_reset(p);
}
#endif
Do you think is here the problem??
Thank you
piccir

Where's the code tag button?
 
Old 04-02-2010, 10:47 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
Ok ... so first, the CODE tags are right next to the QUOTE tags, its the one with a # on it.

Secondly, without pouring through your code line by line and based on the error message,
I would guess two of the culprits might be:

Quote:
valuemask = CWEventMask | CWBackPixel | CWColormap;

hints.flags = PSize | PMinSize | PMaxSize;
Both seem to be setting some attributes / flags so could be the issue.

If not I would suggest looking at each line that takes parameters into functions and confirming
they have a) the right number of arguments and b) the correct arguments.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
After Reinstall, My openGL programs give X error of failed request BadColor Invalid C tethysgods Linux - Software 2 08-16-2008 08:31 AM
X Error of failed request - when open a new tab in gnome-terminal quanta Fedora 0 03-17-2008 10:02 PM
BadMatch error when loading programs from VNC homerpnp Slackware 0 11-10-2006 02:54 PM
X Error of failed request: BadAccess Magmagal Linux - Software 1 10-22-2004 10:39 AM
X Error of failed request BadAccess (X_StoreColors) Magmagal Linux - Software 0 08-10-2004 06:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration