Panics · P01 Primitives: init returns an error, a missing app icon logs and shows a broken picture
This commit is contained in:
1 parent
52d3d790b1
commit
e5166e9e26
20 files changed
+159
-87
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user