Skip to content

fix(cef): import gtk prelude for Linux dialog (TAURI-RUST-F)#18

Merged
M3gA-Mind merged 2 commits into
tinyhumansai:feat/ceffrom
oxoxDev:fix/tauri-rust-f-gtk-prelude-linux
Jun 5, 2026
Merged

fix(cef): import gtk prelude for Linux dialog (TAURI-RUST-F)#18
M3gA-Mind merged 2 commits into
tinyhumansai:feat/ceffrom
oxoxDev:fix/tauri-rust-f-gtk-prelude-linux

Conversation

@oxoxDev

@oxoxDev oxoxDev commented Jun 5, 2026

Copy link
Copy Markdown

Summary

Two compile fixes for breakage introduced by #17's merged code (commit 8ea806e): a Linux-only gtk trait-import error and a macOS-only unsafe-call error. Both live in crates/tauri-runtime-cef/src/cef_init_guard.rs.

Problem

#17 added a graceful CEF-init failure dialog with per-platform native implementations. Two of those paths fail to compile:

Linux — the gtk_impl path calls dialog.set_title(...) and dialog.run() on a gtk::MessageDialog, but the module never brings the gtk extension traits into scope. set_title is GtkWindowExt::set_title and run is DialogExt::run — without those traits in scope the Linux target fails:

error[E0599]: no method named `set_title` found for struct `MessageDialog`
error[E0599]: no method named `run` found for struct `MessageDialog`

It was caught by the downstream cargo-llvm-cov Linux coverage job.

macOS — the macos path calls four objc2 NSAlert methods (NSAlert::new, setMessageText, setInformativeText, runModal) that are marked unsafe in objc2-app-kit, but invokes them outside any unsafe {} block, so cargo check -p tauri-runtime-cef fails on macOS:

error[E0133]: call to unsafe function `NSAlert::new` is unsafe and requires unsafe block
error[E0133]: call to unsafe function `setMessageText` is unsafe and requires unsafe block
error[E0133]: call to unsafe function `setInformativeText` is unsafe and requires unsafe block
error[E0133]: call to unsafe function `runModal` is unsafe and requires unsafe block

Both breaks are pre-existing in #17, not introduced by this PR — this PR fixes them.

Solution

  • Linux: add use gtk::prelude::{DialogExt, GtkWindowExt}; inside the gtk_impl module — the two traits that provide run and set_title.
  • macOS: wrap the four consecutive NSAlert calls in a single enclosing unsafe {} block with a // SAFETY: note (fresh receiver, valid strings, main thread guaranteed by the MainThreadMarker). No suppression attributes.

Surgical, single-file changes; no behavior change on any platform.

Impact

  • Linux target compiles again (gtk trait imports).
  • macOS target compiles again (cargo check -p tauri-runtime-cef passes clean; four E0133 gone, no new warnings).
  • Windows unaffected (separate Win32 dialog impl, untouched).

Related

Summary by CodeRabbit

  • Chores
    • Improved macOS native alert handling by clarifying safety boundaries around system UI calls.
    • Restored Linux/BSD build compatibility by ensuring necessary GTK dialog methods are available, fixing related compilation issues.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 40c105bb-94e9-4e2e-b6b0-6879069f1858

📥 Commits

Reviewing files that changed from the base of the PR and between 74b0e65 and b66905b.

📒 Files selected for processing (1)
  • crates/tauri-runtime-cef/src/cef_init_guard.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/tauri-runtime-cef/src/cef_init_guard.rs

📝 Walkthrough

Walkthrough

Wraps macOS NSAlert usage in an explicit unsafe block with updated safety comments; and imports gtk::prelude::{DialogExt, GtkWindowExt} in the Linux/BSD gtk_impl module so set_title and run are available.

Changes

Platform-specific UI fixes

Layer / File(s) Summary
macOS NSAlert safety
crates/tauri-runtime-cef/src/cef_init_guard.rs
Moves NSAlert construction and setMessageText/setInformativeText/runModal calls into an explicit unsafe block and updates safety comments about receiver/lifetime and main-thread requirement.
Linux/BSD GTK prelude imports
crates/tauri-runtime-cef/src/cef_init_guard.rs
Adds gtk::prelude::{DialogExt, GtkWindowExt} in the gtk_impl conditional to bring set_title and run extension methods into scope for the dialog.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A tiny hop, a careful sight,
Unsafe wrapped the macOS light,
GTK traits find their place,
Dialogs run with gentle grace,
Builds proceed — a quiet delight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a gtk prelude import to fix Linux compilation errors in the CEF dialog implementation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@M3gA-Mind M3gA-Mind merged commit 5ec3d88 into tinyhumansai:feat/cef Jun 5, 2026
1 check 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