【发布时间】:2017-09-26 21:30:30
【问题描述】:
我使用与 MSYS2 一起安装的最新 GTK+,每当我尝试使用
g_application_send_notification() 它总是导致以下结果
断言:
(Notification Project.exe:27780): GLib-GObject-CRITICAL **: g_object_new:
assertion 'G_TYPE_IS_OBJECT (object_type)' failed
为什么我认为这是一个错误 - 因为我在我的旁边尝试了许多代码示例 (无论如何,它们都非常像地雷),让它工作的人 (包括 Lars Uebernickel 的通知),这一切都一样 哀叹。 断言,然后是崩溃。现在我真的不知道这意味着什么,因为它 可能在 gtk 内部,但我真的希望你们中的一些人可能有 这方面的线索或经验。
- 安装 (GNU coreutils) 8.25
- GIO 版本 2.52.3
- mingw32/mingw-w64-i686-gtk-engine-unico 1.0.2-2 [已安装]
- mingw32/mingw-w64-i686-gtk3 3.22.16-1 [已安装]
- mingw32/mingw-w64-i686-gtkmm3 3.22.0-1 [已安装]
- mingw32/mingw-w64-i686-spice-gtk 0.33-1 [已安装]
- mingw32/mingw-w64-i686-webkitgtk3 2.4.11-4 [已安装]
- mingw64/mingw-w64-x86_64-gtk-engine-unico 1.0.2-2 [已安装]
- mingw64/mingw-w64-x86_64-gtk3 3.22.16-1 [已安装]
- mingw64/mingw-w64-x86_64-gtkmm3 3.22.0-1 [已安装]
- mingw64/mingw-w64-x86_64-spice-gtk 0.33-1 [已安装]
- mingw64/mingw-w64-x86_64-webkitgtk3 2.4.11-4 [已安装]
生成此断言的代码示例:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gtk/gtk.h>
#define ICON_PATH "/path/trash_16x16.gif"
int main (int argc, char *argv[])
{
GApplication *app;
app = g_application_new ("org.one", G_APPLICATION_FLAGS_NONE);
if(!app)
{
g_print ("Error app\n");
}
else
{
if(g_application_register (app, NULL, NULL))
{
GNotification *notification;
GFile *file;
GIcon *icon;
notification = g_notification_new ("one");
g_notification_set_body (notification, "Hello world");
file = g_file_new_for_path (ICON_PATH);
icon = g_file_icon_new (file);
g_notification_set_icon (notification, G_ICON (icon));
g_application_send_notification (app, NULL, notification);
g_object_unref (icon);
g_object_unref (file);
g_object_unref (notification);
g_object_unref (app);
g_print ("yes\n");
}
else
{
g_print ("no\n");
}
}
return 0;
}
我能做些什么来绕过这个问题,甚至可以解决它吗?
【问题讨论】:
-
首先,SO 不是 GTK 错误跟踪器,所以为什么要在这里发帖?如果您希望我们让您放心,您应该发布 MCVE。
-
@EugeneSh 对不起,如果我误解了,什么是 MCVE?也不是针对与编程相关的问题。这是编程相关的问题。
-
如果问题中包含您对 g_application_send_notification 的调用,您的问题会更好。但我认为这可能无关紧要,所以:我没有反对
-
stackoverflow.com/help/mcve 是的,它是针对与编程相关的问题。但我在这里没有看到任何问题。
-
@JoséFonte 谢谢 :) 如果我找到解决方案。我会发布它。