-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from RedMser/godot-rust-0.2-stable
Fix editor crash issues
- Loading branch information
Showing
6 changed files
with
37 additions
and
25 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
godot/default/addons/godot-fluent-translation/godot-fluent-translation.gdextension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
godot/forked/addons/godot-fluent-translation/godot-fluent-translation.gdextension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
use godot::prelude::*; | ||
use godot::classes::ResourceLoader; | ||
use godot::classes::{Engine, ResourceLoader}; | ||
|
||
use super::ResourceFormatLoaderFluent; | ||
|
||
/// Singleton for handling Fluent Translation. For internal use only. | ||
#[derive(GodotClass)] | ||
#[class(base=Object, init)] | ||
pub struct FluentI18nSingleton { | ||
loader: Gd<ResourceFormatLoaderFluent>, | ||
loader: Option<Gd<ResourceFormatLoaderFluent>>, | ||
} | ||
|
||
impl FluentI18nSingleton { | ||
pub(crate) const SINGLETON_NAME: &'static str = "FluentI18nSingleton"; | ||
|
||
pub(crate) fn register(&self) { | ||
ResourceLoader::singleton().add_resource_format_loader(&self.loader); | ||
pub(crate) fn register(&mut self) { | ||
// HACK: Resource format loader crashes editor on startup, see https://github.com/godot-rust/gdext/issues/597 | ||
if !Engine::singleton().is_editor_hint() { | ||
self.loader = Some(ResourceFormatLoaderFluent::new_gd()); | ||
ResourceLoader::singleton().add_resource_format_loader(&self.loader.clone().unwrap()); | ||
} | ||
} | ||
|
||
pub(crate) fn unregister(&self) { | ||
ResourceLoader::singleton().remove_resource_format_loader(&self.loader); | ||
if let Some(loader) = &self.loader { | ||
ResourceLoader::singleton().remove_resource_format_loader(loader); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters