【问题标题】:GDK ESourceRegistry Used to Work but Not AnymoreGDK ESourceRegistry 以前可以工作,但现在不行了
【发布时间】:2015-03-02 10:35:36
【问题描述】:

我正在开发使用 libedataserver.so 的 Thunderbird 插件。

Addon 使用 js-ctypes 从上述库中调用 e_source_registry_new_sync。见以下代码:

    var lib = ctypes.open("libedataserver-1.2.so.18");

    var GCancellable = {};
    GCancellable.cls = new ctypes.StructType("GCancellable");
    var GError = {};
    GError.cls = new ctypes.StructType("GError");

    var ESourceRegistry = {};
    ESourceRegistry.cls = new ctypes.StructType("ESourceRegistry");
    ESourceRegistry.e_source_registry_new_sync =
        lib.declare(
            "e_source_registry_new_sync",
            ctypes.default_abi,
            ESourceRegistry.cls.ptr,
            GCancellable.cls.ptr,
            GError.cls.ptr.ptr);

    //below line causes an error
    var sourceRegistry = ESourceRegistry.e_source_registry_new_sync(null, null);

它在 Ubuntu 上运行良好,但在 Fedora 21 上它打印在输出下方并挂起:

(thunderbird:2735): GLib-GObject-WARNING **: cannot register existing type 'EDBusSource'
(thunderbird:2735): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed
(thunderbird:2735): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed
(thunderbird:2735): GLib-GObject-WARNING **: invalid cast from 'EDBusSourceProxy' to '<invalid>'

我正在使用 Fedora 21 和进化数据服务器 3.12.11-1.fc21。

Ubuntu 使用 Evolution-data-server 3.12.10。

我开发了一个简单的 C 应用程序,它调用 e_source_registry_new_sync 并且运行良好。

有人可以提出这个问题的原因吗?

@更新: 我提出了Fedora bug。根据 Fedora 维护者的说法,问题是由两次加载 libedataserver 引起的(我的代码和 evolution-ews):

问题似乎是 Thunderbird 自己加载 libedataserver-1.2.so.18,而 libcamelews.so 对 libedataserver-1.2.so 有运行时依赖,但这不是(在运行时)thunderbird 满足的-loaded libedataserver-1.2.so.18,因此再次加载,破坏了GLib类型系统。

如果我可以从插件方面做些什么,请发表评论。

【问题讨论】:

  • 嘿@Mateusz 这是个好问题。它没有引起太多关注,因为标签在 jsctypes 人中并不流行。粘贴 firefox-addon 标签,您将获得更快的响应 :) 您可以发布您的代码,以便我可以在 ubuntu 和 fedora 上进行测试
  • 感谢 Fedora 团队分享您的评论。我想我们可以解决这个问题。你知道检查哪些库被加载到雷鸟中的方法吗?如果没有,我们可以找到,我们也会运行一个东西来找到你所有的 libedataserver-1.2.so 的路径,并从所有这些路径中尝试。可能是 Thunderbird 已经加载了该库,但路径不同,所以它被双重加载请尝试进入 #jsctypes 频道,我们可以将其淘汰

标签: firefox-addon gtk3 thunderbird-addon jsctypes


【解决方案1】:

您正在询问此函数发生的错误:https://developer.gnome.org/libedataserver/stable/ESourceRegistry.html#e-source-registry-new-sync

文档指出,如果出现错误,将返回 NULL 并适当设置 GError。稍后我会测试代码,看看发生了什么,但我会在这里告诉你如何自己测试。

GError 不是一个 opque 结构。像这样定义它:

var GQuark = ctypes.uint32_t;
GError.cls = new ctypes.StructType('GError', [
    {'domain': GQuark},
    {'code': ctypes.int},
    {'message': ctypes.char.ptr}
]);

取自这里:https://gist.github.com/Noitidart/dbe54fcd7794c8ddff6f#file-_ff-addon-snippet-gdk_giolaunch-js-L22

然后设置您的代码以返回如下错误:

var error = GError.cls.ptr(); // can use `null` if we dont care to see error but we want to know what is happening so we can fix it
var sourceRegistry = ESourceRegistry.e_source_registry_new_sync(null, error.address());
if (sourceRegistry.isNull()) {
    console.error('An error occured when calling e_source_registry_new_sync!');
    console.info('ERROR DETAILS', 'Domain:', error.contents.domain.toString(), 'Code:', error.contents.code, 'Message:', error.contents.message.readString());
}

然后根据错误详细信息查找该代码和消息,它会告诉您发生了什么,然后搜索 StackOverflow 或任何地方寻找解决方案,如果它不明显。

【讨论】:

  • 感谢您的评论。问题是永远无法到达sourceRegistry.isNull()。代码卡在:ESourceRegistry.e_source_registry_new_sync(null, error.address());
  • @MateuszBalbus 这非常奇怪,我复制粘贴了代码,它在 Ubuntu 上运行良好。你能进入 moz IRC 频道#jsctypes 你可以使用这个在线聊天客户端:client00.chat.mibbit.com/… 我们可以帮你解决这个问题
  • 如帖子中所述:“它在 Ubuntu 上运行良好,但在 Fedora 21 上运行良好” 您需要安装了 evolution-ews 的 Fedora 21(应默认安装)。卸载evolution-ews 解决了这个问题。
  • 啊,我明白了,如果你可以聊天,我想我们可以解决这个问题。我们可能不得不拉一些其他人参与对话,但我们会完成的。只要你有空
猜你喜欢
  • 1970-01-01
  • 2014-11-15
  • 2019-02-03
  • 1970-01-01
  • 1970-01-01
  • 2021-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多