1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

[Editor] Better expose EditorDebuggerPlugin.

Now splitted into two classes:
- EditorDebuggerPlugin (RefCounted).
- EditorDebuggerSession (abstract).

This allows the EditorPlugin to be in control of the debugger plugin
lifecycle, be notified when sessions are created, and customize each of
them independently.

We should slowly transition the various profilers and captures in
ScriptEditorDebugger to their own plugins, and decouple
ScriptEditorDebugger from it's UI part (making it the "real"
EditorDebuggerSession potentially dropping the wrappers).
This commit is contained in:
Fabio Alessandrelli
2022-10-03 15:21:25 +02:00
parent 471c42ee1f
commit d568b25e36
12 changed files with 371 additions and 202 deletions

View File

@@ -35,29 +35,62 @@
class ScriptEditorDebugger;
class EditorDebuggerPlugin : public Control {
GDCLASS(EditorDebuggerPlugin, Control);
class EditorDebuggerSession : public RefCounted {
GDCLASS(EditorDebuggerSession, RefCounted);
private:
HashSet<Control *> tabs;
ScriptEditorDebugger *debugger = nullptr;
void _breaked(bool p_really_did, bool p_can_debug, String p_message, bool p_has_stackdump);
void _started();
void _stopped();
void _debugger_gone_away();
protected:
static void _bind_methods();
public:
void attach_debugger(ScriptEditorDebugger *p_debugger);
void detach_debugger(bool p_call_debugger);
void send_message(const String &p_message, const Array &p_args);
void register_message_capture(const StringName &p_name, const Callable &p_callable);
void unregister_message_capture(const StringName &p_name);
bool has_capture(const StringName &p_name);
void detach_debugger();
void add_session_tab(Control *p_tab);
void remove_session_tab(Control *p_tab);
void send_message(const String &p_message, const Array &p_args = Array());
void toggle_profiler(const String &p_profiler, bool p_enable, const Array &p_data = Array());
bool is_breaked();
bool is_debuggable();
bool is_session_active();
bool is_active();
EditorDebuggerSession(ScriptEditorDebugger *p_debugger);
~EditorDebuggerSession();
};
class EditorDebuggerPlugin : public RefCounted {
GDCLASS(EditorDebuggerPlugin, RefCounted);
private:
List<Ref<EditorDebuggerSession>> sessions;
protected:
static void _bind_methods();
public:
void create_session(ScriptEditorDebugger *p_debugger);
void clear();
virtual void setup_session(int p_idx);
virtual bool capture(const String &p_message, const Array &p_data, int p_session);
virtual bool has_capture(const String &p_capture) const;
Ref<EditorDebuggerSession> get_session(int p_session_id);
Array get_sessions();
GDVIRTUAL3R(bool, _capture, const String &, const Array &, int);
GDVIRTUAL1RC(bool, _has_capture, const String &);
GDVIRTUAL1(_setup_session, int);
EditorDebuggerPlugin() {}
~EditorDebuggerPlugin();
};