Skip to content

fix: avoid icon theme init when GTK is not initialized - #5

Merged
Zeno-sole merged 1 commit into
masterfrom
fix-gtk4.18-gir-introspection
Sep 14, 2026
Merged

Zeno-sole merged 1 commit into
masterfrom
fix-gtk4.18-gir-introspection

Conversation

@Zeno-sole

Copy link
Copy Markdown
Contributor

问题

GTK 4.18 环境下 evolution-data-server 3.50.1 构建失败(shuttle task 596422,amd64 与 aarch64 均失败),卡在 76%:

(process:28335): Gdk-ERROR **: 10:11:03.016: gdk_display_manager_get() was called before gtk_init()
Command '[.../tmp-introspectrrtz_ief/EDataServerUI4-1.0', '--introspect-dump=...']' died with <Signals.SIGTRAP: 5>
make[3]: *** [.../EDataServerUI4-1.0.gir] Error 1
make[1]: *** [Makefile:149: all] Error 2
dh_auto_build: error: cd obj-x86_64-linux-gnu && make -j64 "INSTALL=install --strip-program=true" VERBOSE=1 returned exit code 2

同一份日志里 GTK3 的 EDataServerUI-1.2 gir 正常生成,只有 GTK4 的 EDataServerUI4-1.0 失败。构建环境 GTK 为 4.18.6(libgtk-4-1_4.18.6+ds-2deepin1_amd64.deb)。

根因

GTK 4.18 起 gdk_display_manager_get() 内部新增了 gdk_ensure_initialized(),在 gtk_init() 之前调用会 g_error 致命退出(4.16 及更早是无条件创建 display manager,所以此前无害)。

eds 侧的调用链是:_libedataserverui_init_icon_theme()src/libedataserverui/libedataserverui-private.c:68)调用 gdk_display_manager_get(),而该函数又被 ECredentialsPrompterImplPasswordclass_init() 调用(src/libedataserverui/e-credentials-prompter-impl-password.c:592)。g-ir-scanner 在 dump 类型信息时会触发 class_init,于是 introspection 辅助程序在 GTK 尚未初始化时撞上新检查,SIGTRAP 退出。

修复

backport 上游提交 fab47760d3aa("I#571 - libedataserverui: Avoid initializing the icon_theme when building introspection data"),在 #if GTK_CHECK_VERSION(4, 0, 0) 分支开头加 gtk_is_initialized() 守卫。

gtk_is_initialized() 自 GTK 4.4 起提供,正是 configure 要求的最低 GTK 版本;e_source_registry_debug_print() 在 3.50.1 的 src/libedataserver/e-data-server-util.h 中已存在(经 libedataserver.h 引入)。运行时该函数只在 GTK 已初始化后才会走到这里,因此既有行为不变。

按规范只改 debian/:源码改动以 quilt 补丁形式加入 debian/patches/ 并写入 series,版本 3.50.1-13.50.1-1deepin1

验证

  • 本机 GTK 同为 4.18.6,用最小复现程序确认:不加守卫时 gdk_display_manager_get() 触发完全相同的 Gdk-ERROR 并且进程收到 SIGTRAP(exit 133);加上 gtk_is_initialized() 守卫后正常返回 0,且守卫判断前 gtk_is_initialized() 为 FALSE,说明守卫正好覆盖 introspection 场景。
  • dpkg-source --before-build . 三个补丁(含本补丁)全部干净应用,--after-build 正常回退,源码树保持 pristine。
  • 未做完整编译验证:本机缺 14 个 build-dep(libsoup-3.0-dev、libwebkitgtk-6.0-dev 等),建议合入后走集成构建确认 EDataServerUI4-1.0.gir 正常生成。

影响面

  • 仅影响「GTK 未初始化时」的 icon theme 初始化,运行时路径不受影响;
  • 证书信任提示与凭据提示框的图标加载(均在 gtk_init() 之后)行为不变;
  • 不影响 GTK3 版 libedataserverui,也不影响 GTK 版本较旧的架构。

Backport upstream commit fab47760d3aa ("I#571 - libedataserverui: Avoid
initializing the icon_theme when building introspection data") so that
evolution-data-server 3.50.1 builds against GTK 4.18.

GTK 4.18 made gdk_display_manager_get() call gdk_ensure_initialized()
internally, so calling it before gtk_init() now aborts the process:

  Gdk-ERROR **: gdk_display_manager_get() was called before gtk_init()

_libedataserverui_init_icon_theme() is called from the class_init() of
ECredentialsPrompterImplPassword, which g-ir-scanner triggers while
dumping type information. Generating EDataServerUI4-1.0.gir therefore
killed the introspection helper with SIGTRAP and the build failed at
76% (shuttle task 596422, amd64 and aarch64 alike), while the GTK3
EDataServerUI-1.2 gir was generated fine in the same run.

Guard the call with gtk_is_initialized(), which is available since
GTK 4.4 (the minimum version required by configure). At runtime the
function is only reached with GTK already initialized, so the guard
only skips the initialization during introspection/documentation
builds.

Log: Fixed the GTK 4.18 build failure of EDataServerUI4-1.0.gir

Influence:
1. Rebuild the package and confirm EDataServerUI4-1.0.gir is generated
2. Verify libedataserverui4 and its credentials prompter work in
   evolution with GTK 4.18
3. Check that certificate trust prompts still pick up the bundled icons
4. Ensure no regression on GTK 3 builds of libedataserverui
5. Confirm the package still builds on architectures with older GTK

fix: GTK 未初始化时跳过 icon theme 初始化

backport 上游提交 fab47760d3aa("I#571 - libedataserverui: Avoid
initializing the icon_theme when building introspection data"),使
evolution-data-server 3.50.1 能在 GTK 4.18 下构建。

GTK 4.18 给 gdk_display_manager_get() 内部加了 gdk_ensure_initialized(),
未先 gtk_init() 就调用会直接致命退出:

  Gdk-ERROR **: gdk_display_manager_get() was called before gtk_init()

_libedataserverui_init_icon_theme() 由 ECredentialsPrompterImplPassword
的 class_init() 调用,而 g-ir-scanner 在 dump 类型信息时会触发 class_init,
于是生成 EDataServerUI4-1.0.gir 时辅助程序死于 SIGTRAP,构建在 76% 处
失败(shuttle 任务 596422,amd64 与 aarch64 均如此),而同一次构建里
GTK3 的 EDataServerUI-1.2 gir 正常生成。

用 gtk_is_initialized() 守卫该调用(自 GTK 4.4 起提供,正是 configure
要求的最低版本)。运行时该函数只会在 GTK 已初始化后进入,因此该守卫
只影响 introspection 与文档构建,不改变既有行为。

Log: 修复 GTK 4.18 下 EDataServerUI4-1.0.gir 生成失败导致的构建中断

Influence:
1. 重新构建软件包,确认 EDataServerUI4-1.0.gir 正常生成
2. 在 GTK 4.18 下验证 libedataserverui4 及其凭据提示框在 evolution 中正常
3. 检查证书信任提示仍能加载随包提供的图标
4. 确保 GTK 3 版 libedataserverui 构建无回归
5. 确认在 GTK 版本较旧的架构上仍能正常构建

repo: evolution-data-server #master
@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from zeno-sole. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown

TAG Bot

TAG: 3.50.1-1deepin1
EXISTED: no
DISTRIBUTION: unstable

@Zeno-sole

Copy link
Copy Markdown
Contributor Author

/integrate

@github-actions

Copy link
Copy Markdown

AutoIntegrationPr Bot
auto integrate with pr url: deepin-community/Repository-Integration#4562
PrNumber: 4562
PrBranch: auto-integration-34836960836

@Zeno-sole
Zeno-sole merged commit 3337d52 into master Sep 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants