Panics · P01 Primitives: init returns an error, a missing app icon logs and shows a broken picture

This commit is contained in:
ZacharyZhang-NY committed 2026-10-06 15:25:09 -04:00
1 parent 52d3d790b1
commit e5166e9e26
20 files changed
+159 -87

No files matched your search

+1 -1
View File
@@ -54,7 +54,7 @@ fn main() {
gpui_platform::application()
.with_assets(Assets)
.run(|cx: &mut App| {
ely_gpui_component::init(cx);
ely_gpui_component::init(cx).expect("Ely failed to start");
cx.open_window(WindowOptions::default(), |window, cx| {
cx.new(|cx| {
let root = cx.focus_handle();
+1 -1
View File
@@ -41,7 +41,7 @@ fn main() {
gpui_platform::application()
.with_assets(Assets)
.run(|cx: &mut App| {
ely_gpui_component::init(cx);
ely_gpui_component::init(cx).expect("Ely failed to start");
cx.open_window(WindowOptions::default(), |window, cx| {
cx.new(|cx| {
let focus = cx.focus_handle();
+1 -1
View File
@@ -53,7 +53,7 @@ fn main() {
gpui_platform::application()
.with_assets(Assets)
.run(|cx: &mut App| {
ely_gpui_component::init(cx);
ely_gpui_component::init(cx).expect("Ely failed to start");
cx.set_global(
I18n::new("en-US")
.catalog(
+1 -1
View File
@@ -87,7 +87,7 @@ fn main() {
gpui_platform::application()
.with_assets(AppAssets)
.run(|cx: &mut App| {
ely_gpui_component::init(cx);
ely_gpui_component::init(cx).expect("Ely failed to start");
IconTheme::default()
.name("Cargo.toml", IconName::Package)
.apply(cx);
+1 -1
View File
@@ -104,7 +104,7 @@ fn main() {
gpui_platform::application()
.with_assets(Assets)
.run(|cx: &mut App| {
ely_gpui_component::init(cx);
ely_gpui_component::init(cx).expect("Ely failed to start");
cx.open_window(WindowOptions::default(), |window, cx| {
cx.new(|cx| {
let focus = cx.focus_handle();
+1 -1
View File
@@ -78,7 +78,7 @@ fn main() {
gpui_platform::application()
.with_assets(Assets)
.run(|cx: &mut App| {
ely_gpui_component::init(cx);
ely_gpui_component::init(cx).expect("Ely failed to start");
cx.open_window(WindowOptions::default(), |window, cx| {
cx.new(|cx| {
let focus = cx.focus_handle();
+1 -1
View File
@@ -56,7 +56,7 @@ fn main() {
gpui_platform::application()
.with_assets(Assets)
.run(|cx: &mut App| {
ely_gpui_component::init(cx);
ely_gpui_component::init(cx).expect("Ely failed to start");
cx.open_window(WindowOptions::default(), |window, cx| {
cx.new(|cx| {
let focus = cx.focus_handle();
+1 -1
View File
@@ -45,7 +45,7 @@ fn main() {
gpui_platform::application()
.with_assets(Assets)
.run(|cx: &mut App| {
ely_gpui_component::init(cx);
ely_gpui_component::init(cx).expect("Ely failed to start");
Theme::set_mode_now(Mode::Dark, cx);
let bounds = Bounds::centered(None, size(px(640.0), px(400.0)), cx);
let options = WindowOptions {
+1 -1
View File
@@ -100,7 +100,7 @@ fn main() {
gpui_platform::application()
.with_assets(Assets)
.run(|cx: &mut App| {
ely_gpui_component::init(cx);
ely_gpui_component::init(cx).expect("Ely failed to start");
cx.open_window(WindowOptions::default(), |window, cx| {
cx.new(|cx| {
let focus = cx.focus_handle();
+13 -6
View File
@@ -41,7 +41,8 @@ mod web;
use std::path::PathBuf;
#[cfg(not(target_family = "wasm"))]
use anyhow::{Context as _, Result, bail};
use anyhow::bail;
use anyhow::{Context as _, Result};
#[cfg(not(target_family = "wasm"))]
use assets::GalleryAssets;
use ely_gpui_component::theme::{Mode, Theme};
@@ -113,8 +114,8 @@ pub struct Start {
}
/// Sets Ely up and opens the gallery's window.
fn launch(start: Start, cx: &mut App) -> WindowHandle<shell::Gallery> {
ely_gpui_component::init(cx);
fn launch(start: Start, cx: &mut App) -> Result<WindowHandle<shell::Gallery>> {
ely_gpui_component::init(cx)?;
#[cfg(debug_assertions)]
ely_gpui_component::tooling::install_inspector(cx);
pages::bind_keys(cx);
@@ -142,10 +143,10 @@ fn launch(start: Start, cx: &mut App) -> WindowHandle<shell::Gallery> {
.open_window(options, |window, cx| {
cx.new(|cx| shell::Gallery::new(start, window, cx))
})
.expect("gallery window failed to open");
.context("gallery window failed to open")?;
menu_actions(window, cx);
cx.activate(true);
window
Ok(window)
}
#[cfg(not(target_family = "wasm"))]
@@ -204,7 +205,13 @@ fn main() -> Result<()> {
gpui_platform::application()
.with_assets(GalleryAssets)
.run(move |cx: &mut App| {
let window = launch(start, cx);
let window = match launch(start, cx) {
Ok(window) => window,
Err(error) => {
log::error!("gallery: {error:#}");
return cx.quit();
}
};
if let Some(dir) = capture {
capture::run(window, dir, page, scripted, cx);
}
+4 -1
View File
@@ -106,7 +106,10 @@ pub fn start() {
if let Some(choice) = EARLY.take() {
start.choice = choice;
}
let window = launch(start, cx);
let window = match launch(start, cx) {
Ok(window) => window,
Err(error) => return log::error!("gallery: {error:#}"),
};
HOST.with(|host| *host.borrow_mut() = Some((cx.to_async(), window)));
});
}