4141#include " core/os/time.h"
4242#include " editor/debugger/editor_debugger_node.h"
4343#include " editor/debugger/script_editor_debugger.h"
44+ #include " editor/docks/inspector_dock.h"
4445#include " editor/editor_node.h"
46+ #include " editor/inspector/editor_inspector.h"
4547#include " editor/themes/editor_scale.h"
4648#include " scene/gui/button.h"
4749#include " scene/gui/label.h"
@@ -167,7 +169,7 @@ TreeItem *ObjectDBProfilerPanel::_add_snapshot_button(const String &p_snapshot_f
167169void ObjectDBProfilerPanel::_show_selected_snapshot () {
168170 if (snapshot_list->get_selected ()->get_text (0 ) == (String)diff_button->get_selected_metadata ()) {
169171 for (int i = 0 ; i < diff_button->get_item_count (); i++) {
170- if (diff_button->get_item_text (i) == current_snapshot->get_snapshot ()-> name ) {
172+ if (diff_button->get_item_text (i) == current_snapshot->name ) {
171173 diff_button->select (i);
172174 break ;
173175 }
@@ -184,7 +186,7 @@ void ObjectDBProfilerPanel::_on_snapshot_deselected() {
184186 _update_enabled_diff_items ();
185187}
186188
187- Ref<GameStateSnapshotRef > ObjectDBProfilerPanel::get_snapshot (const String &p_snapshot_file_name) {
189+ Ref<GameStateSnapshot > ObjectDBProfilerPanel::get_snapshot (const String &p_snapshot_file_name) {
188190 if (snapshot_cache.has (p_snapshot_file_name)) {
189191 return snapshot_cache.get (p_snapshot_file_name);
190192 }
@@ -201,7 +203,7 @@ Ref<GameStateSnapshotRef> ObjectDBProfilerPanel::get_snapshot(const String &p_sn
201203 Vector<uint8_t > content = snapshot_file->get_buffer (snapshot_file->get_length ()); // We want to split on newlines, so normalize them.
202204 ERR_FAIL_COND_V_MSG (content.is_empty (), nullptr , " ObjectDB Snapshot file is empty: " + full_file_path);
203205
204- Ref<GameStateSnapshotRef > snapshot = GameStateSnapshot::create_ref (p_snapshot_file_name, content);
206+ Ref<GameStateSnapshot > snapshot = GameStateSnapshot::create_ref (p_snapshot_file_name, content);
205207 if (snapshot.is_valid ()) {
206208 snapshot_cache.insert (p_snapshot_file_name, snapshot);
207209 }
@@ -225,8 +227,8 @@ void ObjectDBProfilerPanel::_view_tab_changed(int p_tab_idx) {
225227 // Populating tabs only on tab changed because we're handling a lot of data,
226228 // and the editor freezes for a while if we try to populate every tab at once.
227229 SnapshotView *view = cast_to<SnapshotView>(view_tabs->get_current_tab_control ());
228- GameStateSnapshot *snapshot = current_snapshot.is_null () ? nullptr : current_snapshot-> get_snapshot ();
229- GameStateSnapshot *diff = diff_snapshot.is_null () ? nullptr : diff_snapshot-> get_snapshot ();
230+ GameStateSnapshot *snapshot = current_snapshot.ptr ();
231+ GameStateSnapshot *diff = diff_snapshot.ptr ();
230232 if (snapshot != nullptr && !view->is_showing_snapshot (snapshot, diff)) {
231233 view->show_snapshot (snapshot, diff);
232234 }
@@ -237,6 +239,11 @@ void ObjectDBProfilerPanel::clear_snapshot(bool p_update_view_tabs) {
237239 view->clear_snapshot ();
238240 }
239241
242+ const Object *edited_object = InspectorDock::get_inspector_singleton ()->get_edited_object ();
243+ if (Object::cast_to<SnapshotDataObject>(edited_object)) {
244+ EditorNode::get_singleton ()->push_item (nullptr );
245+ }
246+
240247 current_snapshot.unref ();
241248 diff_snapshot.unref ();
242249
@@ -333,7 +340,7 @@ void ObjectDBProfilerPanel::_edit_snapshot_name() {
333340ObjectDBProfilerPanel::ObjectDBProfilerPanel () {
334341 set_name (TTRC (" ObjectDB Profiler" ));
335342
336- snapshot_cache = LRUCache<String, Ref<GameStateSnapshotRef >>(SNAPSHOT_CACHE_MAX_SIZE);
343+ snapshot_cache = LRUCache<String, Ref<GameStateSnapshot >>(SNAPSHOT_CACHE_MAX_SIZE);
337344
338345 EditorDebuggerNode::get_singleton ()->get_current_debugger ()->connect (" breaked" , callable_mp (this , &ObjectDBProfilerPanel::_on_debug_breaked));
339346
0 commit comments