diff options
Diffstat (limited to 'editor/create_dialog.cpp')
-rw-r--r-- | editor/create_dialog.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index f9858aa514..50e1d03663 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -377,8 +377,8 @@ void CreateDialog::_confirmed() { return; } - FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::WRITE); - if (f) { + Ref<FileAccess> f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::WRITE); + if (f.is_valid()) { f->store_line(selected_item); for (int i = 0; i < MIN(32, recent->get_item_count()); i++) { @@ -386,8 +386,6 @@ void CreateDialog::_confirmed() { f->store_line(recent->get_item_text(i)); } } - - memdelete(f); } // To prevent, emitting an error from the transient window (shader dialog for example) hide this dialog before emitting the "create" signal. @@ -647,8 +645,8 @@ void CreateDialog::_save_and_update_favorite_list() { favorites->clear(); TreeItem *root = favorites->create_item(); - FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::WRITE); - if (f) { + Ref<FileAccess> f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::WRITE); + if (f.is_valid()) { for (int i = 0; i < favorite_list.size(); i++) { String l = favorite_list[i]; String name = l.get_slicec(' ', 0); @@ -665,7 +663,6 @@ void CreateDialog::_save_and_update_favorite_list() { ti->set_text(0, l); ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(name, icon_fallback)); } - memdelete(f); } emit_signal(SNAME("favorites_updated")); @@ -673,8 +670,8 @@ void CreateDialog::_save_and_update_favorite_list() { void CreateDialog::_load_favorites_and_history() { String dir = EditorSettings::get_singleton()->get_project_settings_dir(); - FileAccess *f = FileAccess::open(dir.plus_file("create_recent." + base_type), FileAccess::READ); - if (f) { + Ref<FileAccess> f = FileAccess::open(dir.plus_file("create_recent." + base_type), FileAccess::READ); + if (f.is_valid()) { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); String name = l.get_slicec(' ', 0); @@ -683,12 +680,10 @@ void CreateDialog::_load_favorites_and_history() { recent->add_item(l, EditorNode::get_singleton()->get_class_icon(name, icon_fallback)); } } - - memdelete(f); } f = FileAccess::open(dir.plus_file("favorites." + base_type), FileAccess::READ); - if (f) { + if (f.is_valid()) { while (!f->eof_reached()) { String l = f->get_line().strip_edges(); @@ -696,8 +691,6 @@ void CreateDialog::_load_favorites_and_history() { favorite_list.push_back(l); } } - - memdelete(f); } } |