| 576 | } |
| 577 | |
| 578 | void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_enabled) { |
| 579 | Ref<Script> scr = Object::cast_to<Script>(*p_script); |
| 580 | if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) { |
| 581 | // Update if open. |
| 582 | for (int i = 0; i < tab_container->get_tab_count(); i++) { |
| 583 | ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); |
| 584 | if (se && se->get_edited_resource()->get_path() == scr->get_path()) { |
| 585 | se->set_breakpoint(p_line, p_enabled); |
| 586 | return; |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | // Handle closed. |
| 591 | Dictionary state = script_editor_cache->get_value(scr->get_path(), "state"); |
| 592 | Array breakpoints; |
| 593 | if (state.has("breakpoints")) { |
| 594 | breakpoints = state["breakpoints"]; |
| 595 | } |
| 596 | |
| 597 | if (breakpoints.has(p_line)) { |
| 598 | if (!p_enabled) { |
| 599 | breakpoints.erase(p_line); |
| 600 | } |
| 601 | } else if (p_enabled) { |
| 602 | breakpoints.push_back(p_line); |
| 603 | } |
| 604 | state["breakpoints"] = breakpoints; |
| 605 | script_editor_cache->set_value(scr->get_path(), "state", state); |
| 606 | EditorDebuggerNode::get_singleton()->set_breakpoint(scr->get_path(), p_line + 1, p_enabled); |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | void ScriptEditor::_clear_breakpoints() { |
| 611 | for (int i = 0; i < tab_container->get_tab_count(); i++) { |
nothing calls this directly
no test coverage detected