无法使用 XFreeColors() 释放 Xlib 中的颜色图条目

发布于 2024-07-26 12:03:58 字数 610 浏览 11 评论 0原文

我使用下一个代码分配一个颜色条目,然后用它来正确绘制:

char *color_name = "red";
XColor color, exact;

XAllocNamedColor(display, colormap, color_name, &color, &exact);

然后,当我不再需要颜色条目时,我尝试释放它:

XFreeColors(display, colormap, &color.pixel, 1, 0);

此调用会生成下一个错误:

 Error of failed request:  BadAccess (attempt to access private resource denied)
 Major opcode of failed request:  88 (X_FreeColors)
 Serial number of failed request:  17
 Current serial number in output stream:  19

我有什么东西吗?做错了吗? 我怎样才能释放该颜色条目? 该颜色条目应该被释放吗?

I allocate a color entry with the next code, then I use it to draw correctly:

char *color_name = "red";
XColor color, exact;

XAllocNamedColor(display, colormap, color_name, &color, &exact);

Then, when I don't need anymore the color entry, I try to free it:

XFreeColors(display, colormap, &color.pixel, 1, 0);

This call generates the next error:

 Error of failed request:  BadAccess (attempt to access private resource denied)
 Major opcode of failed request:  88 (X_FreeColors)
 Serial number of failed request:  17
 Current serial number in output stream:  19

Is there something I'm doing wrong? How can I free that color entry? That color entry should be freed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘦怹 2024-08-02 12:03:58

已解决:我正在对 XFreeColors 进行两次调用:

XFreeColors(display, colormap, &color.pixel, 1, 0);
XFreeColors(display, colormap, &exact.pixel, 1, 0);

第二个调用绝对不能完成,这是没有必要的。

Solved: I was doing two call to XFreeColors:

XFreeColors(display, colormap, &color.pixel, 1, 0);
XFreeColors(display, colormap, &exact.pixel, 1, 0);

The second call with exact must not be done, it's not necessary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文