Skip to content

Commit

Permalink
Remove unused function reload()
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Oct 26, 2024
1 parent 9303b02 commit 3223c40
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 45 deletions.
44 changes: 0 additions & 44 deletions src/elf/script_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,47 +499,3 @@ Sandbox *ELFScriptInstance::create_sandbox(const Ref<ELFScript> &p_script) {

return sandbox_ptr;
}

void ELFScriptInstance::reload(ELFScript *p_script) {
auto old_script = std::move(this->script);
this->script = Ref<ELFScript>(p_script);
this->update_methods();
bool update_program = false;

auto it = sandbox_instances.find(old_script.ptr());
if (it != sandbox_instances.end()) {
Sandbox *sandbox_ptr = it->second;
this->current_sandbox = sandbox_ptr;
// Remove the old script instance and insert the new one
sandbox_instances.erase(it);
sandbox_instances.insert_or_assign(p_script, sandbox_ptr);
update_program = true;
}

if (!update_program) {
Sandbox *sandbox_ptr = Object::cast_to<Sandbox>(this->owner);
if (sandbox_ptr != nullptr) {
this->current_sandbox = sandbox_ptr;
update_program = true;
}
}

if (!update_program) {
ERR_PRINT("ELFScriptInstance: Did not reload a Sandbox instance");
if constexpr (VERBOSE_LOGGING) {
fprintf(stderr, "ELFScriptInstance: owner is instead a '%s'!\n", this->owner->get_class().utf8().get_data());
}
} else {
// Set the new program, with potentially new parent Node
current_sandbox->set_tree_base(godot::Object::cast_to<godot::Node>(this->owner));
current_sandbox->set_program(this->script);

if constexpr (VERBOSE_LOGGING) {
ERR_PRINT("ELFScriptInstance: reloaded " + Object::cast_to<Node>(owner)->get_name());
}
// Update editor properties
if (this->owner != nullptr) {
this->owner->notify_property_list_changed();
}
}
}
1 change: 0 additions & 1 deletion src/elf/script_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class ELFScriptInstance : public ScriptInstanceExtension {
mutable bool has_updated_methods = false;
bool auto_created_sandbox = false;

void reload(ELFScript *p_script);
void update_methods() const;

// Retrieve the sandbox and whether it was created automatically or not
Expand Down

0 comments on commit 3223c40

Please sign in to comment.