Initialize Application::name in multi-window runtime
This commit is contained in:
parent
780af771fa
commit
4890d75012
4 changed files with 17 additions and 4 deletions
|
|
@ -78,6 +78,8 @@ mod internal {
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
|
|
||||||
pub fn init(name: &str) {
|
pub fn init(name: &str) {
|
||||||
|
let name = name.split("::").next().unwrap_or(name);
|
||||||
|
|
||||||
name.clone_into(&mut NAME.write().expect("Write application name"));
|
name.clone_into(&mut NAME.write().expect("Write application name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,11 @@ where
|
||||||
/// The data needed to initialize your [`Application`].
|
/// The data needed to initialize your [`Application`].
|
||||||
type Flags;
|
type Flags;
|
||||||
|
|
||||||
|
/// Returns the unique name of the [`Application`].
|
||||||
|
fn name() -> &'static str {
|
||||||
|
std::any::type_name::<Self>()
|
||||||
|
}
|
||||||
|
|
||||||
/// Initializes the [`Application`] with the flags provided to
|
/// Initializes the [`Application`] with the flags provided to
|
||||||
/// [`run`] as part of the [`Settings`].
|
/// [`run`] as part of the [`Settings`].
|
||||||
///
|
///
|
||||||
|
|
@ -232,6 +237,10 @@ where
|
||||||
(Instance(app), command)
|
(Instance(app), command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn name() -> &'static str {
|
||||||
|
A::name()
|
||||||
|
}
|
||||||
|
|
||||||
fn title(&self, window: window::Id) -> String {
|
fn title(&self, window: window::Id) -> String {
|
||||||
self.0.title(window)
|
self.0.title(window)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,7 @@ where
|
||||||
type Executor = executor::Default;
|
type Executor = executor::Default;
|
||||||
|
|
||||||
fn name() -> &'static str {
|
fn name() -> &'static str {
|
||||||
let type_name = std::any::type_name::<State>();
|
std::any::type_name::<State>()
|
||||||
|
|
||||||
type_name.split("::").next().unwrap_or(type_name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load(&self) -> Command<Self::Message> {
|
fn load(&self) -> Command<Self::Message> {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@ where
|
||||||
/// The data needed to initialize your [`Application`].
|
/// The data needed to initialize your [`Application`].
|
||||||
type Flags;
|
type Flags;
|
||||||
|
|
||||||
|
/// Returns the unique name of the [`Application`].
|
||||||
|
fn name() -> &'static str;
|
||||||
|
|
||||||
/// Initializes the [`Application`] with the flags provided to
|
/// Initializes the [`Application`] with the flags provided to
|
||||||
/// [`run`] as part of the [`Settings`].
|
/// [`run`] as part of the [`Settings`].
|
||||||
///
|
///
|
||||||
|
|
@ -117,6 +120,7 @@ where
|
||||||
{
|
{
|
||||||
use winit::event_loop::EventLoop;
|
use winit::event_loop::EventLoop;
|
||||||
|
|
||||||
|
debug::init(A::name());
|
||||||
let boot_span = debug::boot();
|
let boot_span = debug::boot();
|
||||||
|
|
||||||
let event_loop = EventLoop::with_user_event()
|
let event_loop = EventLoop::with_user_event()
|
||||||
|
|
@ -989,7 +993,6 @@ fn update<A: Application, C, E: Executor>(
|
||||||
for message in messages.drain(..) {
|
for message in messages.drain(..) {
|
||||||
let update_span = debug::update(&message);
|
let update_span = debug::update(&message);
|
||||||
let command = runtime.enter(|| application.update(message));
|
let command = runtime.enter(|| application.update(message));
|
||||||
update_span.finish();
|
|
||||||
|
|
||||||
run_command(
|
run_command(
|
||||||
application,
|
application,
|
||||||
|
|
@ -1002,6 +1005,7 @@ fn update<A: Application, C, E: Executor>(
|
||||||
window_manager,
|
window_manager,
|
||||||
ui_caches,
|
ui_caches,
|
||||||
);
|
);
|
||||||
|
update_span.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
let recipes = application.subscription().into_recipes();
|
let recipes = application.subscription().into_recipes();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue