Skip to content

Commit

Permalink
Merge pull request #48 from RedMser/fix-4.3-crash
Browse files Browse the repository at this point in the history
Cargo: update all dependencies to latest version
  • Loading branch information
RedMser authored Nov 13, 2024
2 parents 58f6fbb + 5e10578 commit 3a674b4
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 117 deletions.
84 changes: 42 additions & 42 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions rust/src/fluent/editor_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ impl IEditorPlugin for FluentEditorPlugin {
fn enter_tree(&mut self) {
let export_plugin = FluentExportPlugin::new_gd();
self.export_plugin = Some(export_plugin.clone());
self.base_mut().add_export_plugin(export_plugin);
self.base_mut().add_export_plugin(&export_plugin);
}

fn exit_tree(&mut self) {
let export_plugin = self.export_plugin.take();
self.base_mut().remove_export_plugin(export_plugin);
self.export_plugin = None;
if let Some(export_plugin) = self.export_plugin.take() {
self.base_mut().remove_export_plugin(&export_plugin);
self.export_plugin = None;
}
}
}
8 changes: 4 additions & 4 deletions rust/src/fluent/export_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl IEditorExportPlugin for FluentExportPlugin {
}

fn get_export_options(&self, _platform: Option<Gd<EditorExportPlatform>>) -> Array<Dictionary> {
array![dict! {
array![&dict! {
"option": dict! {
"name": GString::from(EXPORT_OPTION_STRIP_COMMENTS),
"type": VariantType::BOOL,
Expand All @@ -36,13 +36,13 @@ impl IEditorExportPlugin for FluentExportPlugin {
return;
}

if self.base().get_option(StringName::from(EXPORT_OPTION_STRIP_COMMENTS)).booleanize() {
if self.base().get_option(EXPORT_OPTION_STRIP_COMMENTS).booleanize() {
// Strip comments from file
let contents = strip_comments(path.clone());
let contents = strip_comments(&path);
let binary = PackedByteArray::from_iter(contents.bytes());

self.base_mut().skip();
self.base_mut().add_file(path, binary, false);
self.base_mut().add_file(&path, &binary, false);
}
}

Expand Down
20 changes: 10 additions & 10 deletions rust/src/fluent/extractor_packed_scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ pub struct FluentPackedSceneTranslationParser {
/// Main difference is that it does not (yet) call parsers recursively.
impl FluentTranslationParser for FluentPackedSceneTranslationParser {
fn get_recognized_extensions(&self) -> Vec<GString> {
ResourceLoader::singleton().get_recognized_extensions_for_type("PackedScene".into()).to_vec()
ResourceLoader::singleton().get_recognized_extensions_for_type("PackedScene").to_vec()
}

fn extract_messages(&self, path: &GString) -> MessageGeneration {
let class_db = ClassDb::singleton();

let loaded_res = ResourceLoader::singleton().load_ex(path.clone())
.type_hint("PackedScene".into())
let loaded_res = ResourceLoader::singleton().load_ex(path)
.type_hint("PackedScene")
.cache_mode(CacheMode::REUSE)
.done();
if loaded_res.is_none() {
Expand Down Expand Up @@ -92,7 +92,7 @@ impl FluentTranslationParser for FluentPackedSceneTranslationParser {
tabcontainer_paths.pop();
}

if auto_translating && !tabcontainer_paths.is_empty() && class_db.is_parent_class(node_type.clone(), "Control".into())
if auto_translating && !tabcontainer_paths.is_empty() && class_db.is_parent_class(&node_type, "Control")
&& GString::from(parent_path) == tabcontainer_paths[((tabcontainer_paths.len() as i64) - 1) as usize] {
parsed_strings.push(GString::from(state.get_node_name(i)));
}
Expand Down Expand Up @@ -162,15 +162,15 @@ impl FluentTranslationParser for FluentPackedSceneTranslationParser {
impl FluentPackedSceneTranslationParser {
pub fn init() -> Self {
let lookup_properties = ["^text$", "^.+_text$", "^popup/.+/text$", "^title$", "^filters$", /* "^script$", */]
.map(|str| RegEx::create_from_string(str.into()).unwrap())
.map(|str| RegEx::create_from_string(str).unwrap())
.into();
let exception_list = [
("LineEdit", ["^text$"]),
("TextEdit", ["^text$"]),
("CodeEdit", ["^text$"]),
].map(|(typename, strs)|
(StringName::from(typename), HashSet::from(
strs.map(|str| RegEx::create_from_string(str.into()).unwrap())
strs.map(|str| RegEx::create_from_string(str).unwrap())
))
)
.into();
Expand All @@ -185,20 +185,20 @@ impl FluentPackedSceneTranslationParser {
let class_db = ClassDb::singleton();

for (exception_node_type, exception_properties) in &self.exception_list {
if class_db.is_parent_class(node_type.clone(), exception_node_type.clone()) &&
if class_db.is_parent_class(node_type, exception_node_type) &&
exception_properties.iter().any(|exception_property|
Self::matches(GString::from(property_name), exception_property.clone())
Self::matches(&GString::from(property_name), exception_property.clone())
) {
return false;
}
}

self.lookup_properties.iter().any(|lookup_property|
Self::matches(GString::from(property_name), lookup_property.clone())
Self::matches(&GString::from(property_name), lookup_property.clone())
)
}

fn matches(string: GString, pattern: Gd<RegEx>) -> bool {
fn matches(string: &GString, pattern: Gd<RegEx>) -> bool {
pattern.search(string).is_some()
}
}
Loading

0 comments on commit 3a674b4

Please sign in to comment.