script_editor_debugger.cpp 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900
  1. /*************************************************************************/
  2. /* script_editor_debugger.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "script_editor_debugger.h"
  31. #include "editor_node.h"
  32. #include "editor_profiler.h"
  33. #include "editor_settings.h"
  34. #include "main/performance.h"
  35. #include "project_settings.h"
  36. #include "property_editor.h"
  37. #include "scene/gui/dialogs.h"
  38. #include "scene/gui/label.h"
  39. #include "scene/gui/line_edit.h"
  40. #include "scene/gui/margin_container.h"
  41. #include "scene/gui/rich_text_label.h"
  42. #include "scene/gui/separator.h"
  43. #include "scene/gui/split_container.h"
  44. #include "scene/gui/tab_container.h"
  45. #include "scene/gui/texture_button.h"
  46. #include "scene/gui/tree.h"
  47. class ScriptEditorDebuggerVariables : public Object {
  48. GDCLASS(ScriptEditorDebuggerVariables, Object);
  49. List<PropertyInfo> props;
  50. Map<StringName, Variant> values;
  51. protected:
  52. bool _set(const StringName &p_name, const Variant &p_value) {
  53. return false;
  54. }
  55. bool _get(const StringName &p_name, Variant &r_ret) const {
  56. if (!values.has(p_name))
  57. return false;
  58. r_ret = values[p_name];
  59. return true;
  60. }
  61. void _get_property_list(List<PropertyInfo> *p_list) const {
  62. for (const List<PropertyInfo>::Element *E = props.front(); E; E = E->next())
  63. p_list->push_back(E->get());
  64. }
  65. public:
  66. void clear() {
  67. props.clear();
  68. values.clear();
  69. }
  70. String get_var_value(const String &p_var) const {
  71. for (Map<StringName, Variant>::Element *E = values.front(); E; E = E->next()) {
  72. String v = E->key().operator String().get_slice("/", 1);
  73. if (v == p_var)
  74. return E->get();
  75. }
  76. return "";
  77. }
  78. void add_property(const String &p_name, const Variant &p_value, const PropertyHint &p_hint, const String p_hint_string) {
  79. PropertyInfo pinfo;
  80. pinfo.name = p_name;
  81. pinfo.type = p_value.get_type();
  82. pinfo.hint = p_hint;
  83. pinfo.hint_string = p_hint_string;
  84. props.push_back(pinfo);
  85. values[p_name] = p_value;
  86. }
  87. void update() {
  88. _change_notify();
  89. }
  90. ScriptEditorDebuggerVariables() {
  91. }
  92. };
  93. class ScriptEditorDebuggerInspectedObject : public Object {
  94. GDCLASS(ScriptEditorDebuggerInspectedObject, Object);
  95. protected:
  96. bool _set(const StringName &p_name, const Variant &p_value) {
  97. if (!prop_values.has(p_name))
  98. return false;
  99. emit_signal("value_edited", p_name, p_value);
  100. prop_values[p_name] = p_value;
  101. return true;
  102. }
  103. bool _get(const StringName &p_name, Variant &r_ret) const {
  104. if (!prop_values.has(p_name))
  105. return false;
  106. r_ret = prop_values[p_name];
  107. return true;
  108. }
  109. void _get_property_list(List<PropertyInfo> *p_list) const {
  110. p_list->clear(); //sorry, no want category
  111. for (const List<PropertyInfo>::Element *E = prop_list.front(); E; E = E->next()) {
  112. p_list->push_back(E->get());
  113. }
  114. }
  115. static void _bind_methods() {
  116. ADD_SIGNAL(MethodInfo("value_edited"));
  117. }
  118. public:
  119. ObjectID last_edited_id;
  120. List<PropertyInfo> prop_list;
  121. Map<StringName, Variant> prop_values;
  122. void update() {
  123. _change_notify();
  124. }
  125. void update_single(const char *p_prop) {
  126. _change_notify(p_prop);
  127. }
  128. ScriptEditorDebuggerInspectedObject() { last_edited_id = 0; }
  129. };
  130. void ScriptEditorDebugger::debug_next() {
  131. ERR_FAIL_COND(!breaked);
  132. ERR_FAIL_COND(connection.is_null());
  133. ERR_FAIL_COND(!connection->is_connected_to_host());
  134. Array msg;
  135. msg.push_back("next");
  136. ppeer->put_var(msg);
  137. stack_dump->clear();
  138. inspector->edit(NULL);
  139. }
  140. void ScriptEditorDebugger::debug_step() {
  141. ERR_FAIL_COND(!breaked);
  142. ERR_FAIL_COND(connection.is_null());
  143. ERR_FAIL_COND(!connection->is_connected_to_host());
  144. Array msg;
  145. msg.push_back("step");
  146. ppeer->put_var(msg);
  147. stack_dump->clear();
  148. inspector->edit(NULL);
  149. }
  150. void ScriptEditorDebugger::debug_break() {
  151. ERR_FAIL_COND(breaked);
  152. ERR_FAIL_COND(connection.is_null());
  153. ERR_FAIL_COND(!connection->is_connected_to_host());
  154. Array msg;
  155. msg.push_back("break");
  156. ppeer->put_var(msg);
  157. }
  158. void ScriptEditorDebugger::debug_continue() {
  159. ERR_FAIL_COND(!breaked);
  160. ERR_FAIL_COND(connection.is_null());
  161. ERR_FAIL_COND(!connection->is_connected_to_host());
  162. OS::get_singleton()->enable_for_stealing_focus(EditorNode::get_singleton()->get_child_process_id());
  163. Array msg;
  164. msg.push_back("continue");
  165. ppeer->put_var(msg);
  166. }
  167. void ScriptEditorDebugger::_scene_tree_folded(Object *obj) {
  168. if (updating_scene_tree) {
  169. return;
  170. }
  171. TreeItem *item = obj->cast_to<TreeItem>();
  172. if (!item)
  173. return;
  174. ObjectID id = item->get_metadata(0);
  175. if (item->is_collapsed()) {
  176. unfold_cache.erase(id);
  177. } else {
  178. unfold_cache.insert(id);
  179. }
  180. }
  181. void ScriptEditorDebugger::_scene_tree_selected() {
  182. if (updating_scene_tree) {
  183. return;
  184. }
  185. TreeItem *item = inspect_scene_tree->get_selected();
  186. if (!item) {
  187. return;
  188. }
  189. inspected_object_id = item->get_metadata(0);
  190. Array msg;
  191. msg.push_back("inspect_object");
  192. msg.push_back(inspected_object_id);
  193. ppeer->put_var(msg);
  194. }
  195. void ScriptEditorDebugger::_scene_tree_property_value_edited(const String &p_prop, const Variant &p_value) {
  196. Array msg;
  197. msg.push_back("set_object_property");
  198. msg.push_back(inspected_object_id);
  199. msg.push_back(p_prop);
  200. msg.push_back(p_value);
  201. ppeer->put_var(msg);
  202. inspect_edited_object_timeout = 0.7; //avoid annoyance, don't request soon after editing
  203. }
  204. void ScriptEditorDebugger::_scene_tree_property_select_object(ObjectID p_object) {
  205. inspected_object_id = p_object;
  206. Array msg;
  207. msg.push_back("inspect_object");
  208. msg.push_back(inspected_object_id);
  209. ppeer->put_var(msg);
  210. }
  211. void ScriptEditorDebugger::_scene_tree_request() {
  212. ERR_FAIL_COND(connection.is_null());
  213. ERR_FAIL_COND(!connection->is_connected_to_host());
  214. Array msg;
  215. msg.push_back("request_scene_tree");
  216. ppeer->put_var(msg);
  217. }
  218. void ScriptEditorDebugger::_video_mem_request() {
  219. ERR_FAIL_COND(connection.is_null());
  220. ERR_FAIL_COND(!connection->is_connected_to_host());
  221. Array msg;
  222. msg.push_back("request_video_mem");
  223. ppeer->put_var(msg);
  224. }
  225. Size2 ScriptEditorDebugger::get_minimum_size() const {
  226. Size2 ms = Control::get_minimum_size();
  227. ms.y = MAX(ms.y, 250);
  228. return ms;
  229. }
  230. void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_data) {
  231. if (p_msg == "debug_enter") {
  232. Array msg;
  233. msg.push_back("get_stack_dump");
  234. ppeer->put_var(msg);
  235. ERR_FAIL_COND(p_data.size() != 2);
  236. bool can_continue = p_data[0];
  237. String error = p_data[1];
  238. step->set_disabled(!can_continue);
  239. next->set_disabled(!can_continue);
  240. reason->set_text(error);
  241. reason->set_tooltip(error);
  242. breaked = true;
  243. dobreak->set_disabled(true);
  244. docontinue->set_disabled(false);
  245. emit_signal("breaked", true, can_continue);
  246. OS::get_singleton()->move_window_to_foreground();
  247. if (error != "") {
  248. tabs->set_current_tab(0);
  249. }
  250. profiler->set_enabled(false);
  251. EditorNode::get_singleton()->get_pause_button()->set_pressed(true);
  252. EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
  253. } else if (p_msg == "debug_exit") {
  254. breaked = false;
  255. step->set_disabled(true);
  256. next->set_disabled(true);
  257. reason->set_text("");
  258. reason->set_tooltip("");
  259. back->set_disabled(true);
  260. forward->set_disabled(true);
  261. dobreak->set_disabled(false);
  262. docontinue->set_disabled(true);
  263. emit_signal("breaked", false, false, Variant());
  264. //tabs->set_current_tab(0);
  265. profiler->set_enabled(true);
  266. profiler->disable_seeking();
  267. EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
  268. } else if (p_msg == "message:click_ctrl") {
  269. clicked_ctrl->set_text(p_data[0]);
  270. clicked_ctrl_type->set_text(p_data[1]);
  271. } else if (p_msg == "message:scene_tree") {
  272. inspect_scene_tree->clear();
  273. Map<int, TreeItem *> lv;
  274. updating_scene_tree = true;
  275. for (int i = 0; i < p_data.size(); i += 4) {
  276. TreeItem *p;
  277. int level = p_data[i];
  278. if (level == 0) {
  279. p = NULL;
  280. } else {
  281. ERR_CONTINUE(!lv.has(level - 1));
  282. p = lv[level - 1];
  283. }
  284. TreeItem *it = inspect_scene_tree->create_item(p);
  285. ObjectID id = ObjectID(p_data[i + 3]);
  286. it->set_text(0, p_data[i + 1]);
  287. if (has_icon(p_data[i + 2], "EditorIcons"))
  288. it->set_icon(0, get_icon(p_data[i + 2], "EditorIcons"));
  289. it->set_metadata(0, id);
  290. if (id == inspected_object_id) {
  291. it->select(0);
  292. }
  293. if (p) {
  294. if (!unfold_cache.has(id)) {
  295. it->set_collapsed(true);
  296. }
  297. } else {
  298. if (unfold_cache.has(id)) { //reverse for root
  299. it->set_collapsed(true);
  300. }
  301. }
  302. lv[level] = it;
  303. }
  304. updating_scene_tree = false;
  305. le_clear->set_disabled(false);
  306. le_set->set_disabled(false);
  307. } else if (p_msg == "message:inspect_object") {
  308. ObjectID id = p_data[0];
  309. String type = p_data[1];
  310. Variant path = p_data[2]; //what to do yet, i don't know
  311. int prop_count = p_data[3];
  312. int idx = 4;
  313. if (inspected_object->last_edited_id != id) {
  314. inspected_object->prop_list.clear();
  315. inspected_object->prop_values.clear();
  316. }
  317. for (int i = 0; i < prop_count; i++) {
  318. PropertyInfo pinfo;
  319. pinfo.name = p_data[idx++];
  320. pinfo.type = Variant::Type(int(p_data[idx++]));
  321. pinfo.hint = PropertyHint(int(p_data[idx++]));
  322. pinfo.hint_string = p_data[idx++];
  323. if (pinfo.name.begins_with("*")) {
  324. pinfo.name = pinfo.name.substr(1, pinfo.name.length());
  325. pinfo.usage = PROPERTY_USAGE_CATEGORY;
  326. } else {
  327. pinfo.usage = PROPERTY_USAGE_EDITOR;
  328. }
  329. if (inspected_object->last_edited_id != id) {
  330. //don't update.. it's the same, instead refresh
  331. inspected_object->prop_list.push_back(pinfo);
  332. }
  333. inspected_object->prop_values[pinfo.name] = p_data[idx++];
  334. if (inspected_object->last_edited_id == id) {
  335. //same, just update value, don't rebuild
  336. inspected_object->update_single(pinfo.name.ascii().get_data());
  337. }
  338. }
  339. if (inspected_object->last_edited_id != id) {
  340. //only if different
  341. inspected_object->update();
  342. }
  343. inspected_object->last_edited_id = id;
  344. if (tabs->get_current_tab() == 2) {
  345. inspect_properties->edit(inspected_object);
  346. } else {
  347. editor->push_item(inspected_object);
  348. }
  349. } else if (p_msg == "message:video_mem") {
  350. vmem_tree->clear();
  351. TreeItem *root = vmem_tree->create_item();
  352. int total = 0;
  353. for (int i = 0; i < p_data.size(); i += 4) {
  354. TreeItem *it = vmem_tree->create_item(root);
  355. String type = p_data[i + 1];
  356. int bytes = p_data[i + 3].operator int();
  357. it->set_text(0, p_data[i + 0]); //path
  358. it->set_text(1, type); //type
  359. it->set_text(2, p_data[i + 2]); //type
  360. it->set_text(3, String::humanize_size(bytes)); //type
  361. total += bytes;
  362. if (has_icon(type, "EditorIcons"))
  363. it->set_icon(0, get_icon(type, "EditorIcons"));
  364. }
  365. vmem_total->set_tooltip(TTR("Bytes:") + " " + itos(total));
  366. vmem_total->set_text(String::humanize_size(total));
  367. } else if (p_msg == "stack_dump") {
  368. stack_dump->clear();
  369. TreeItem *r = stack_dump->create_item();
  370. for (int i = 0; i < p_data.size(); i++) {
  371. Dictionary d = p_data[i];
  372. ERR_CONTINUE(!d.has("function"));
  373. ERR_CONTINUE(!d.has("file"));
  374. ERR_CONTINUE(!d.has("line"));
  375. ERR_CONTINUE(!d.has("id"));
  376. TreeItem *s = stack_dump->create_item(r);
  377. d["frame"] = i;
  378. s->set_metadata(0, d);
  379. //String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"])+" - at func: "+d["function"];
  380. String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]);
  381. s->set_text(0, line);
  382. if (i == 0)
  383. s->select(0);
  384. }
  385. } else if (p_msg == "stack_frame_vars") {
  386. variables->clear();
  387. int ofs = 0;
  388. int mcount = p_data[ofs];
  389. ofs++;
  390. for (int i = 0; i < mcount; i++) {
  391. String n = p_data[ofs + i * 2 + 0];
  392. Variant v = p_data[ofs + i * 2 + 1];
  393. PropertyHint h = PROPERTY_HINT_NONE;
  394. String hs = String();
  395. if (n.begins_with("*")) {
  396. n = n.substr(1, n.length());
  397. h = PROPERTY_HINT_OBJECT_ID;
  398. String s = v;
  399. s = s.replace("[", "");
  400. hs = s.get_slice(":", 0);
  401. v = s.get_slice(":", 1).to_int();
  402. }
  403. variables->add_property("members/" + n, v, h, hs);
  404. }
  405. ofs += mcount * 2;
  406. mcount = p_data[ofs];
  407. ofs++;
  408. for (int i = 0; i < mcount; i++) {
  409. String n = p_data[ofs + i * 2 + 0];
  410. Variant v = p_data[ofs + i * 2 + 1];
  411. PropertyHint h = PROPERTY_HINT_NONE;
  412. String hs = String();
  413. if (n.begins_with("*")) {
  414. n = n.substr(1, n.length());
  415. h = PROPERTY_HINT_OBJECT_ID;
  416. String s = v;
  417. s = s.replace("[", "");
  418. hs = s.get_slice(":", 0);
  419. v = s.get_slice(":", 1).to_int();
  420. }
  421. variables->add_property("locals/" + n, v, h, hs);
  422. }
  423. variables->update();
  424. inspector->edit(variables);
  425. } else if (p_msg == "output") {
  426. //OUT
  427. for (int i = 0; i < p_data.size(); i++) {
  428. String t = p_data[i];
  429. //LOG
  430. if (!EditorNode::get_log()->is_visible()) {
  431. if (EditorNode::get_singleton()->are_bottom_panels_hidden()) {
  432. EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log());
  433. }
  434. }
  435. EditorNode::get_log()->add_message(t);
  436. }
  437. } else if (p_msg == "performance") {
  438. Array arr = p_data[0];
  439. Vector<float> p;
  440. p.resize(arr.size());
  441. for (int i = 0; i < arr.size(); i++) {
  442. p[i] = arr[i];
  443. if (i < perf_items.size()) {
  444. perf_items[i]->set_text(1, rtos(p[i]));
  445. if (p[i] > perf_max[i])
  446. perf_max[i] = p[i];
  447. }
  448. }
  449. perf_history.push_front(p);
  450. perf_draw->update();
  451. } else if (p_msg == "error") {
  452. Array err = p_data[0];
  453. Array vals;
  454. vals.push_back(err[0]);
  455. vals.push_back(err[1]);
  456. vals.push_back(err[2]);
  457. vals.push_back(err[3]);
  458. bool warning = err[9];
  459. bool e;
  460. String time = String("%d:%02d:%02d:%04d").sprintf(vals, &e);
  461. String txt = time + " - " + (err[8].is_zero() ? String(err[7]) : String(err[8]));
  462. String tooltip = TTR("Type:") + String(warning ? TTR("Warning") : TTR("Error"));
  463. tooltip += "\n" + TTR("Description:") + " " + String(err[8]);
  464. tooltip += "\n" + TTR("Time:") + " " + time;
  465. tooltip += "\nC " + TTR("Error:") + " " + String(err[7]);
  466. tooltip += "\nC " + TTR("Source:") + " " + String(err[5]) + ":" + String(err[6]);
  467. tooltip += "\nC " + TTR("Function:") + " " + String(err[4]);
  468. error_list->add_item(txt, EditorNode::get_singleton()->get_gui_base()->get_icon(warning ? "Warning" : "Error", "EditorIcons"));
  469. error_list->set_item_tooltip(error_list->get_item_count() - 1, tooltip);
  470. int scc = p_data[1];
  471. Array stack;
  472. stack.resize(scc);
  473. for (int i = 0; i < scc; i++) {
  474. stack[i] = p_data[2 + i];
  475. }
  476. error_list->set_item_metadata(error_list->get_item_count() - 1, stack);
  477. error_count++;
  478. /*
  479. int count = p_data[1];
  480. Array cstack;
  481. OutputError oe = errors.front()->get();
  482. packet_peer_stream->put_var(oe.hr);
  483. packet_peer_stream->put_var(oe.min);
  484. packet_peer_stream->put_var(oe.sec);
  485. packet_peer_stream->put_var(oe.msec);
  486. packet_peer_stream->put_var(oe.source_func);
  487. packet_peer_stream->put_var(oe.source_file);
  488. packet_peer_stream->put_var(oe.source_line);
  489. packet_peer_stream->put_var(oe.error);
  490. packet_peer_stream->put_var(oe.error_descr);
  491. packet_peer_stream->put_var(oe.warning);
  492. packet_peer_stream->put_var(oe.callstack);
  493. */
  494. } else if (p_msg == "profile_sig") {
  495. //cache a signature
  496. profiler_signature[p_data[1]] = p_data[0];
  497. } else if (p_msg == "profile_frame" || p_msg == "profile_total") {
  498. EditorProfiler::Metric metric;
  499. metric.valid = true;
  500. metric.frame_number = p_data[0];
  501. metric.frame_time = p_data[1];
  502. metric.idle_time = p_data[2];
  503. metric.fixed_time = p_data[3];
  504. metric.fixed_frame_time = p_data[4];
  505. int frame_data_amount = p_data[6];
  506. int frame_function_amount = p_data[7];
  507. if (frame_data_amount) {
  508. EditorProfiler::Metric::Category frame_time;
  509. frame_time.signature = "category_frame_time";
  510. frame_time.name = "Frame Time";
  511. frame_time.total_time = metric.frame_time;
  512. EditorProfiler::Metric::Category::Item item;
  513. item.calls = 1;
  514. item.line = 0;
  515. item.name = "Fixed Time";
  516. item.total = metric.fixed_time;
  517. item.self = item.total;
  518. item.signature = "fixed_time";
  519. frame_time.items.push_back(item);
  520. item.name = "Idle Time";
  521. item.total = metric.idle_time;
  522. item.self = item.total;
  523. item.signature = "idle_time";
  524. frame_time.items.push_back(item);
  525. item.name = "Fixed Frame Time";
  526. item.total = metric.fixed_frame_time;
  527. item.self = item.total;
  528. item.signature = "fixed_frame_time";
  529. frame_time.items.push_back(item);
  530. metric.categories.push_back(frame_time);
  531. }
  532. int idx = 8;
  533. for (int i = 0; i < frame_data_amount; i++) {
  534. EditorProfiler::Metric::Category c;
  535. String name = p_data[idx++];
  536. Array values = p_data[idx++];
  537. c.name = name.capitalize();
  538. c.items.resize(values.size() / 2);
  539. c.total_time = 0;
  540. c.signature = "categ::" + name;
  541. for (int i = 0; i < values.size(); i += 2) {
  542. EditorProfiler::Metric::Category::Item item;
  543. item.name = values[i];
  544. item.calls = 1;
  545. item.self = values[i + 1];
  546. item.total = item.self;
  547. item.signature = "categ::" + name + "::" + item.name;
  548. item.name = item.name.capitalize();
  549. c.total_time += item.total;
  550. c.items[i / 2] = item;
  551. }
  552. metric.categories.push_back(c);
  553. }
  554. EditorProfiler::Metric::Category funcs;
  555. funcs.total_time = p_data[5]; //script time
  556. funcs.items.resize(frame_function_amount);
  557. funcs.name = "Script Functions";
  558. funcs.signature = "script_functions";
  559. for (int i = 0; i < frame_function_amount; i++) {
  560. int signature = p_data[idx++];
  561. int calls = p_data[idx++];
  562. float total = p_data[idx++];
  563. float self = p_data[idx++];
  564. EditorProfiler::Metric::Category::Item item;
  565. if (profiler_signature.has(signature)) {
  566. item.signature = profiler_signature[signature];
  567. String name = profiler_signature[signature];
  568. Vector<String> strings = name.split("::");
  569. if (strings.size() == 3) {
  570. item.name = strings[2];
  571. item.script = strings[0];
  572. item.line = strings[1].to_int();
  573. }
  574. } else {
  575. item.name = "SigErr " + itos(signature);
  576. }
  577. item.calls = calls;
  578. item.self = self;
  579. item.total = total;
  580. funcs.items[i] = item;
  581. }
  582. metric.categories.push_back(funcs);
  583. if (p_msg == "profile_frame")
  584. profiler->add_frame_metric(metric, false);
  585. else
  586. profiler->add_frame_metric(metric, true);
  587. } else if (p_msg == "kill_me") {
  588. editor->call_deferred("stop_child_process");
  589. }
  590. }
  591. void ScriptEditorDebugger::_performance_select(Object *, int, bool) {
  592. perf_draw->update();
  593. }
  594. void ScriptEditorDebugger::_performance_draw() {
  595. Vector<int> which;
  596. for (int i = 0; i < perf_items.size(); i++) {
  597. if (perf_items[i]->is_selected(0))
  598. which.push_back(i);
  599. }
  600. if (which.empty())
  601. return;
  602. Ref<StyleBox> graph_sb = get_stylebox("normal", "TextEdit");
  603. Ref<Font> graph_font = get_font("font", "TextEdit");
  604. int cols = Math::ceil(Math::sqrt((float)which.size()));
  605. int rows = (which.size() + 1) / cols;
  606. if (which.size() == 1)
  607. rows = 1;
  608. int margin = 3;
  609. int point_sep = 5;
  610. Size2i s = Size2i(perf_draw->get_size()) / Size2i(cols, rows);
  611. for (int i = 0; i < which.size(); i++) {
  612. Point2i p(i % cols, i / cols);
  613. Rect2i r(p * s, s);
  614. r.position += Point2(margin, margin);
  615. r.size -= Point2(margin, margin) * 2.0;
  616. perf_draw->draw_style_box(graph_sb, r);
  617. r.position += graph_sb->get_offset();
  618. r.size -= graph_sb->get_minimum_size();
  619. int pi = which[i];
  620. Color c = get_color("success_color", "Editor");
  621. c.set_hsv(Math::fmod(c.get_h() + pi * 0.7654, 1), c.get_s(), c.get_v());
  622. //c = c.linear_interpolate(get_color("base_color", "Editor"), 0.9);
  623. c.a = 0.8;
  624. perf_draw->draw_string(graph_font, r.position + Point2(0, graph_font->get_ascent()), perf_items[pi]->get_text(0), c, r.size.x);
  625. c.a = 0.6;
  626. perf_draw->draw_string(graph_font, r.position + Point2(graph_font->get_char_size('X').width, graph_font->get_ascent() + graph_font->get_height()), perf_items[pi]->get_text(1), c, r.size.y);
  627. float spacing = point_sep / float(cols);
  628. float from = r.size.width;
  629. List<Vector<float> >::Element *E = perf_history.front();
  630. float prev = -1;
  631. while (from >= 0 && E) {
  632. float m = perf_max[pi];
  633. if (m == 0)
  634. m = 0.00001;
  635. float h = E->get()[pi] / m;
  636. h = (1.0 - h) * r.size.y;
  637. c.a = 0.7;
  638. if (E != perf_history.front())
  639. perf_draw->draw_line(r.position + Point2(from, h), r.position + Point2(from + spacing, prev), c, 2.0);
  640. prev = h;
  641. E = E->next();
  642. from -= spacing;
  643. }
  644. }
  645. }
  646. void ScriptEditorDebugger::_notification(int p_what) {
  647. switch (p_what) {
  648. case NOTIFICATION_ENTER_TREE: {
  649. inspector->edit(variables);
  650. step->set_icon(get_icon("DebugStep", "EditorIcons"));
  651. next->set_icon(get_icon("DebugNext", "EditorIcons"));
  652. back->set_icon(get_icon("Back", "EditorIcons"));
  653. forward->set_icon(get_icon("Forward", "EditorIcons"));
  654. dobreak->set_icon(get_icon("Pause", "EditorIcons"));
  655. docontinue->set_icon(get_icon("DebugContinue", "EditorIcons"));
  656. //scene_tree_refresh->set_icon( get_icon("Reload","EditorIcons"));
  657. le_set->connect("pressed", this, "_live_edit_set");
  658. le_clear->connect("pressed", this, "_live_edit_clear");
  659. error_list->connect("item_selected", this, "_error_selected");
  660. error_stack->connect("item_selected", this, "_error_stack_selected");
  661. vmem_refresh->set_icon(get_icon("Reload", "EditorIcons"));
  662. reason->add_color_override("font_color", get_color("error_color", "Editor"));
  663. } break;
  664. case NOTIFICATION_PROCESS: {
  665. if (connection.is_valid()) {
  666. inspect_scene_tree_timeout -= get_process_delta_time();
  667. if (inspect_scene_tree_timeout < 0) {
  668. inspect_scene_tree_timeout = EditorSettings::get_singleton()->get("debugger/scene_tree_refresh_interval");
  669. if (inspect_scene_tree->is_visible_in_tree()) {
  670. _scene_tree_request();
  671. if (inspected_object_id != 0) {
  672. //take the chance and re-inspect selected object
  673. Array msg;
  674. msg.push_back("inspect_object");
  675. msg.push_back(inspected_object_id);
  676. ppeer->put_var(msg);
  677. }
  678. }
  679. }
  680. inspect_edited_object_timeout -= get_process_delta_time();
  681. if (inspect_edited_object_timeout < 0) {
  682. inspect_edited_object_timeout = EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
  683. if (inspect_scene_tree->is_visible_in_tree() && inspected_object_id) {
  684. //take the chance and re-inspect selected object
  685. Array msg;
  686. msg.push_back("inspect_object");
  687. msg.push_back(inspected_object_id);
  688. ppeer->put_var(msg);
  689. }
  690. }
  691. }
  692. if (error_count != last_error_count) {
  693. if (error_count == 0) {
  694. error_split->set_name(TTR("Errors"));
  695. debugger_button->set_text(TTR("Debugger"));
  696. debugger_button->set_icon(Ref<Texture>());
  697. tabs->set_tab_icon(error_split->get_index(), Ref<Texture>());
  698. } else {
  699. error_split->set_name(TTR("Errors") + " (" + itos(error_count) + ")");
  700. debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count) + ")");
  701. debugger_button->set_icon(get_icon("Error", "EditorIcons"));
  702. tabs->set_tab_icon(error_split->get_index(), get_icon("Error", "EditorIcons"));
  703. }
  704. last_error_count = error_count;
  705. }
  706. if (connection.is_null()) {
  707. if (server->is_connection_available()) {
  708. connection = server->take_connection();
  709. if (connection.is_null())
  710. break;
  711. EditorNode::get_log()->add_message("** Debug Process Started **");
  712. ppeer->set_stream_peer(connection);
  713. //EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
  714. //emit_signal("show_debugger",true);
  715. dobreak->set_disabled(false);
  716. tabs->set_current_tab(0);
  717. reason->set_text(TTR("Child Process Connected"));
  718. reason->set_tooltip(TTR("Child Process Connected"));
  719. profiler->clear();
  720. inspect_scene_tree->clear();
  721. le_set->set_disabled(true);
  722. le_clear->set_disabled(false);
  723. error_list->clear();
  724. error_stack->clear();
  725. error_count = 0;
  726. profiler_signature.clear();
  727. //live_edit_root->set_text("/root");
  728. EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
  729. EditorNode::get_singleton()->get_pause_button()->set_disabled(false);
  730. update_live_edit_root();
  731. if (profiler->is_profiling()) {
  732. _profiler_activate(true);
  733. }
  734. } else {
  735. break;
  736. }
  737. };
  738. if (!connection->is_connected_to_host()) {
  739. stop();
  740. editor->notify_child_process_exited(); //somehow, exited
  741. break;
  742. };
  743. if (ppeer->get_available_packet_count() <= 0) {
  744. break;
  745. };
  746. while (ppeer->get_available_packet_count() > 0) {
  747. if (pending_in_queue) {
  748. int todo = MIN(ppeer->get_available_packet_count(), pending_in_queue);
  749. for (int i = 0; i < todo; i++) {
  750. Variant cmd;
  751. Error ret = ppeer->get_var(cmd);
  752. if (ret != OK) {
  753. stop();
  754. ERR_FAIL_COND(ret != OK);
  755. }
  756. message.push_back(cmd);
  757. pending_in_queue--;
  758. }
  759. if (pending_in_queue == 0) {
  760. _parse_message(message_type, message);
  761. message.clear();
  762. }
  763. } else {
  764. if (ppeer->get_available_packet_count() >= 2) {
  765. Variant cmd;
  766. Error ret = ppeer->get_var(cmd);
  767. if (ret != OK) {
  768. stop();
  769. ERR_FAIL_COND(ret != OK);
  770. }
  771. if (cmd.get_type() != Variant::STRING) {
  772. stop();
  773. ERR_FAIL_COND(cmd.get_type() != Variant::STRING);
  774. }
  775. message_type = cmd;
  776. //print_line("GOT: "+message_type);
  777. ret = ppeer->get_var(cmd);
  778. if (ret != OK) {
  779. stop();
  780. ERR_FAIL_COND(ret != OK);
  781. }
  782. if (cmd.get_type() != Variant::INT) {
  783. stop();
  784. ERR_FAIL_COND(cmd.get_type() != Variant::INT);
  785. }
  786. pending_in_queue = cmd;
  787. if (pending_in_queue == 0) {
  788. _parse_message(message_type, Array());
  789. message.clear();
  790. }
  791. } else {
  792. break;
  793. }
  794. }
  795. }
  796. } break;
  797. case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
  798. tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
  799. tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles"));
  800. tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles"));
  801. } break;
  802. }
  803. }
  804. void ScriptEditorDebugger::start() {
  805. stop();
  806. if (is_visible_in_tree()) {
  807. EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
  808. }
  809. perf_history.clear();
  810. for (int i = 0; i < Performance::MONITOR_MAX; i++) {
  811. perf_max[i] = 0;
  812. }
  813. int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
  814. if (server->listen(remote_port) != OK) {
  815. EditorNode::get_log()->add_message(String("** Error listening on port ") + itos(remote_port) + String(" **"));
  816. return;
  817. }
  818. set_process(true);
  819. }
  820. void ScriptEditorDebugger::pause() {
  821. }
  822. void ScriptEditorDebugger::unpause() {
  823. }
  824. void ScriptEditorDebugger::stop() {
  825. set_process(false);
  826. server->stop();
  827. ppeer->set_stream_peer(Ref<StreamPeer>());
  828. if (connection.is_valid()) {
  829. EditorNode::get_log()->add_message("** Debug Process Stopped **");
  830. connection.unref();
  831. }
  832. pending_in_queue = 0;
  833. message.clear();
  834. node_path_cache.clear();
  835. res_path_cache.clear();
  836. profiler_signature.clear();
  837. le_clear->set_disabled(false);
  838. le_set->set_disabled(true);
  839. profiler->set_enabled(true);
  840. inspect_properties->edit(NULL);
  841. inspect_scene_tree->clear();
  842. EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
  843. EditorNode::get_singleton()->get_pause_button()->set_disabled(true);
  844. //avoid confusion when stopped debugging but an object is still edited
  845. EditorNode::get_singleton()->push_item(NULL);
  846. if (hide_on_stop) {
  847. if (is_visible_in_tree())
  848. EditorNode::get_singleton()->hide_bottom_panel();
  849. emit_signal("show_debugger", false);
  850. }
  851. }
  852. void ScriptEditorDebugger::_profiler_activate(bool p_enable) {
  853. if (!connection.is_valid())
  854. return;
  855. if (p_enable) {
  856. profiler_signature.clear();
  857. Array msg;
  858. msg.push_back("start_profiling");
  859. int max_funcs = EditorSettings::get_singleton()->get("debugger/profiler_frame_max_functions");
  860. max_funcs = CLAMP(max_funcs, 16, 512);
  861. msg.push_back(max_funcs);
  862. ppeer->put_var(msg);
  863. print_line("BEGIN PROFILING!");
  864. } else {
  865. Array msg;
  866. msg.push_back("stop_profiling");
  867. ppeer->put_var(msg);
  868. print_line("END PROFILING!");
  869. }
  870. }
  871. void ScriptEditorDebugger::_profiler_seeked() {
  872. if (!connection.is_valid() || !connection->is_connected_to_host())
  873. return;
  874. if (breaked)
  875. return;
  876. debug_break();
  877. }
  878. void ScriptEditorDebugger::_stack_dump_frame_selected() {
  879. TreeItem *ti = stack_dump->get_selected();
  880. if (!ti)
  881. return;
  882. Dictionary d = ti->get_metadata(0);
  883. stack_script = ResourceLoader::load(d["file"]);
  884. emit_signal("goto_script_line", stack_script, int(d["line"]) - 1);
  885. stack_script.unref();
  886. ERR_FAIL_COND(connection.is_null());
  887. ERR_FAIL_COND(!connection->is_connected_to_host());
  888. ///
  889. Array msg;
  890. msg.push_back("get_stack_frame_vars");
  891. msg.push_back(d["frame"]);
  892. ppeer->put_var(msg);
  893. }
  894. void ScriptEditorDebugger::_output_clear() {
  895. //output->clear();
  896. //output->push_color(Color(0,0,0));
  897. }
  898. String ScriptEditorDebugger::get_var_value(const String &p_var) const {
  899. if (!breaked)
  900. return String();
  901. return variables->get_var_value(p_var);
  902. }
  903. int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) {
  904. const int *r = node_path_cache.getptr(p_path);
  905. if (r)
  906. return *r;
  907. last_path_id++;
  908. node_path_cache[p_path] = last_path_id;
  909. Array msg;
  910. msg.push_back("live_node_path");
  911. msg.push_back(p_path);
  912. msg.push_back(last_path_id);
  913. ppeer->put_var(msg);
  914. return last_path_id;
  915. }
  916. int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) {
  917. Map<String, int>::Element *E = res_path_cache.find(p_path);
  918. if (E)
  919. return E->get();
  920. last_path_id++;
  921. res_path_cache[p_path] = last_path_id;
  922. Array msg;
  923. msg.push_back("live_res_path");
  924. msg.push_back(p_path);
  925. msg.push_back(last_path_id);
  926. ppeer->put_var(msg);
  927. return last_path_id;
  928. }
  929. void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
  930. if (!p_base || !live_debug || !connection.is_valid() || !editor->get_edited_scene())
  931. return;
  932. Node *node = p_base->cast_to<Node>();
  933. VARIANT_ARGPTRS
  934. for (int i = 0; i < VARIANT_ARG_MAX; i++) {
  935. //no pointers, sorry
  936. if (argptr[i] && (argptr[i]->get_type() == Variant::OBJECT || argptr[i]->get_type() == Variant::_RID))
  937. return;
  938. }
  939. if (node) {
  940. NodePath path = editor->get_edited_scene()->get_path_to(node);
  941. int pathid = _get_node_path_cache(path);
  942. Array msg;
  943. msg.push_back("live_node_call");
  944. msg.push_back(pathid);
  945. msg.push_back(p_name);
  946. for (int i = 0; i < VARIANT_ARG_MAX; i++) {
  947. //no pointers, sorry
  948. msg.push_back(*argptr[i]);
  949. }
  950. ppeer->put_var(msg);
  951. return;
  952. }
  953. Resource *res = p_base->cast_to<Resource>();
  954. if (res && res->get_path() != String()) {
  955. String respath = res->get_path();
  956. int pathid = _get_res_path_cache(respath);
  957. Array msg;
  958. msg.push_back("live_res_call");
  959. msg.push_back(pathid);
  960. msg.push_back(p_name);
  961. for (int i = 0; i < VARIANT_ARG_MAX; i++) {
  962. //no pointers, sorry
  963. msg.push_back(*argptr[i]);
  964. }
  965. ppeer->put_var(msg);
  966. return;
  967. }
  968. //print_line("method");
  969. }
  970. void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p_property, const Variant &p_value) {
  971. if (!p_base || !live_debug || !connection.is_valid() || !editor->get_edited_scene())
  972. return;
  973. Node *node = p_base->cast_to<Node>();
  974. if (node) {
  975. NodePath path = editor->get_edited_scene()->get_path_to(node);
  976. int pathid = _get_node_path_cache(path);
  977. if (p_value.is_ref()) {
  978. Ref<Resource> res = p_value;
  979. if (res.is_valid() && res->get_path() != String()) {
  980. Array msg;
  981. msg.push_back("live_node_prop_res");
  982. msg.push_back(pathid);
  983. msg.push_back(p_property);
  984. msg.push_back(res->get_path());
  985. ppeer->put_var(msg);
  986. }
  987. } else {
  988. Array msg;
  989. msg.push_back("live_node_prop");
  990. msg.push_back(pathid);
  991. msg.push_back(p_property);
  992. msg.push_back(p_value);
  993. ppeer->put_var(msg);
  994. }
  995. return;
  996. }
  997. Resource *res = p_base->cast_to<Resource>();
  998. if (res && res->get_path() != String()) {
  999. String respath = res->get_path();
  1000. int pathid = _get_res_path_cache(respath);
  1001. if (p_value.is_ref()) {
  1002. Ref<Resource> res = p_value;
  1003. if (res.is_valid() && res->get_path() != String()) {
  1004. Array msg;
  1005. msg.push_back("live_res_prop_res");
  1006. msg.push_back(pathid);
  1007. msg.push_back(p_property);
  1008. msg.push_back(res->get_path());
  1009. ppeer->put_var(msg);
  1010. }
  1011. } else {
  1012. Array msg;
  1013. msg.push_back("live_res_prop");
  1014. msg.push_back(pathid);
  1015. msg.push_back(p_property);
  1016. msg.push_back(p_value);
  1017. ppeer->put_var(msg);
  1018. }
  1019. return;
  1020. }
  1021. //print_line("prop");
  1022. }
  1023. void ScriptEditorDebugger::_method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
  1024. ScriptEditorDebugger *sed = (ScriptEditorDebugger *)p_ud;
  1025. sed->_method_changed(p_base, p_name, VARIANT_ARG_PASS);
  1026. }
  1027. void ScriptEditorDebugger::_property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value) {
  1028. ScriptEditorDebugger *sed = (ScriptEditorDebugger *)p_ud;
  1029. sed->_property_changed(p_base, p_property, p_value);
  1030. }
  1031. void ScriptEditorDebugger::set_live_debugging(bool p_enable) {
  1032. live_debug = p_enable;
  1033. }
  1034. void ScriptEditorDebugger::_live_edit_set() {
  1035. if (!connection.is_valid())
  1036. return;
  1037. TreeItem *ti = inspect_scene_tree->get_selected();
  1038. if (!ti)
  1039. return;
  1040. String path;
  1041. while (ti) {
  1042. String lp = ti->get_text(0);
  1043. path = "/" + lp + path;
  1044. ti = ti->get_parent();
  1045. }
  1046. NodePath np = path;
  1047. editor->get_editor_data().set_edited_scene_live_edit_root(np);
  1048. update_live_edit_root();
  1049. }
  1050. void ScriptEditorDebugger::_live_edit_clear() {
  1051. NodePath np = NodePath("/root");
  1052. editor->get_editor_data().set_edited_scene_live_edit_root(np);
  1053. update_live_edit_root();
  1054. }
  1055. void ScriptEditorDebugger::update_live_edit_root() {
  1056. NodePath np = editor->get_editor_data().get_edited_scene_live_edit_root();
  1057. if (connection.is_valid()) {
  1058. Array msg;
  1059. msg.push_back("live_set_root");
  1060. msg.push_back(np);
  1061. if (editor->get_edited_scene())
  1062. msg.push_back(editor->get_edited_scene()->get_filename());
  1063. else
  1064. msg.push_back("");
  1065. ppeer->put_var(msg);
  1066. }
  1067. live_edit_root->set_text(np);
  1068. }
  1069. void ScriptEditorDebugger::live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name) {
  1070. if (live_debug && connection.is_valid()) {
  1071. Array msg;
  1072. msg.push_back("live_create_node");
  1073. msg.push_back(p_parent);
  1074. msg.push_back(p_type);
  1075. msg.push_back(p_name);
  1076. ppeer->put_var(msg);
  1077. }
  1078. }
  1079. void ScriptEditorDebugger::live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name) {
  1080. if (live_debug && connection.is_valid()) {
  1081. Array msg;
  1082. msg.push_back("live_instance_node");
  1083. msg.push_back(p_parent);
  1084. msg.push_back(p_path);
  1085. msg.push_back(p_name);
  1086. ppeer->put_var(msg);
  1087. }
  1088. }
  1089. void ScriptEditorDebugger::live_debug_remove_node(const NodePath &p_at) {
  1090. if (live_debug && connection.is_valid()) {
  1091. Array msg;
  1092. msg.push_back("live_remove_node");
  1093. msg.push_back(p_at);
  1094. ppeer->put_var(msg);
  1095. }
  1096. }
  1097. void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id) {
  1098. if (live_debug && connection.is_valid()) {
  1099. Array msg;
  1100. msg.push_back("live_remove_and_keep_node");
  1101. msg.push_back(p_at);
  1102. msg.push_back(p_keep_id);
  1103. ppeer->put_var(msg);
  1104. }
  1105. }
  1106. void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos) {
  1107. if (live_debug && connection.is_valid()) {
  1108. Array msg;
  1109. msg.push_back("live_restore_node");
  1110. msg.push_back(p_id);
  1111. msg.push_back(p_at);
  1112. msg.push_back(p_at_pos);
  1113. ppeer->put_var(msg);
  1114. }
  1115. }
  1116. void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name) {
  1117. if (live_debug && connection.is_valid()) {
  1118. Array msg;
  1119. msg.push_back("live_duplicate_node");
  1120. msg.push_back(p_at);
  1121. msg.push_back(p_new_name);
  1122. ppeer->put_var(msg);
  1123. }
  1124. }
  1125. void ScriptEditorDebugger::live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) {
  1126. if (live_debug && connection.is_valid()) {
  1127. Array msg;
  1128. msg.push_back("live_reparent_node");
  1129. msg.push_back(p_at);
  1130. msg.push_back(p_new_place);
  1131. msg.push_back(p_new_name);
  1132. msg.push_back(p_at_pos);
  1133. ppeer->put_var(msg);
  1134. }
  1135. }
  1136. void ScriptEditorDebugger::set_breakpoint(const String &p_path, int p_line, bool p_enabled) {
  1137. if (connection.is_valid()) {
  1138. Array msg;
  1139. msg.push_back("breakpoint");
  1140. msg.push_back(p_path);
  1141. msg.push_back(p_line);
  1142. msg.push_back(p_enabled);
  1143. ppeer->put_var(msg);
  1144. }
  1145. }
  1146. void ScriptEditorDebugger::reload_scripts() {
  1147. if (connection.is_valid()) {
  1148. Array msg;
  1149. msg.push_back("reload_scripts");
  1150. ppeer->put_var(msg);
  1151. }
  1152. }
  1153. void ScriptEditorDebugger::_error_selected(int p_idx) {
  1154. error_stack->clear();
  1155. Array st = error_list->get_item_metadata(p_idx);
  1156. for (int i = 0; i < st.size(); i += 2) {
  1157. String script = st[i];
  1158. int line = st[i + 1];
  1159. Array md;
  1160. md.push_back(st[i]);
  1161. md.push_back(st[i + 1]);
  1162. String str = script.get_file() + ":" + itos(line);
  1163. error_stack->add_item(str);
  1164. error_stack->set_item_metadata(error_stack->get_item_count() - 1, md);
  1165. error_stack->set_item_tooltip(error_stack->get_item_count() - 1, TTR("File:") + " " + String(st[i]) + "\n" + TTR("Line:") + " " + itos(line));
  1166. }
  1167. }
  1168. void ScriptEditorDebugger::_error_stack_selected(int p_idx) {
  1169. Array arr = error_stack->get_item_metadata(p_idx);
  1170. if (arr.size() != 2)
  1171. return;
  1172. Ref<Script> s = ResourceLoader::load(arr[0]);
  1173. emit_signal("goto_script_line", s, int(arr[1]) - 1);
  1174. }
  1175. void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) {
  1176. hide_on_stop = p_hide;
  1177. }
  1178. bool ScriptEditorDebugger::get_debug_with_external_editor() const {
  1179. return enable_external_editor;
  1180. }
  1181. void ScriptEditorDebugger::set_debug_with_external_editor(bool p_enabled) {
  1182. enable_external_editor = p_enabled;
  1183. }
  1184. Ref<Script> ScriptEditorDebugger::get_dump_stack_script() const {
  1185. return stack_script;
  1186. }
  1187. void ScriptEditorDebugger::_paused() {
  1188. ERR_FAIL_COND(connection.is_null());
  1189. ERR_FAIL_COND(!connection->is_connected_to_host());
  1190. if (!breaked && EditorNode::get_singleton()->get_pause_button()->is_pressed()) {
  1191. debug_break();
  1192. }
  1193. if (breaked && !EditorNode::get_singleton()->get_pause_button()->is_pressed()) {
  1194. debug_continue();
  1195. }
  1196. }
  1197. void ScriptEditorDebugger::_bind_methods() {
  1198. ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected);
  1199. ClassDB::bind_method(D_METHOD("debug_next"), &ScriptEditorDebugger::debug_next);
  1200. ClassDB::bind_method(D_METHOD("debug_step"), &ScriptEditorDebugger::debug_step);
  1201. ClassDB::bind_method(D_METHOD("debug_break"), &ScriptEditorDebugger::debug_break);
  1202. ClassDB::bind_method(D_METHOD("debug_continue"), &ScriptEditorDebugger::debug_continue);
  1203. ClassDB::bind_method(D_METHOD("_output_clear"), &ScriptEditorDebugger::_output_clear);
  1204. ClassDB::bind_method(D_METHOD("_performance_draw"), &ScriptEditorDebugger::_performance_draw);
  1205. ClassDB::bind_method(D_METHOD("_performance_select"), &ScriptEditorDebugger::_performance_select);
  1206. ClassDB::bind_method(D_METHOD("_scene_tree_request"), &ScriptEditorDebugger::_scene_tree_request);
  1207. ClassDB::bind_method(D_METHOD("_video_mem_request"), &ScriptEditorDebugger::_video_mem_request);
  1208. ClassDB::bind_method(D_METHOD("_live_edit_set"), &ScriptEditorDebugger::_live_edit_set);
  1209. ClassDB::bind_method(D_METHOD("_live_edit_clear"), &ScriptEditorDebugger::_live_edit_clear);
  1210. ClassDB::bind_method(D_METHOD("_error_selected"), &ScriptEditorDebugger::_error_selected);
  1211. ClassDB::bind_method(D_METHOD("_error_stack_selected"), &ScriptEditorDebugger::_error_stack_selected);
  1212. ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate);
  1213. ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked);
  1214. ClassDB::bind_method(D_METHOD("_paused"), &ScriptEditorDebugger::_paused);
  1215. ClassDB::bind_method(D_METHOD("_scene_tree_selected"), &ScriptEditorDebugger::_scene_tree_selected);
  1216. ClassDB::bind_method(D_METHOD("_scene_tree_folded"), &ScriptEditorDebugger::_scene_tree_folded);
  1217. ClassDB::bind_method(D_METHOD("live_debug_create_node"), &ScriptEditorDebugger::live_debug_create_node);
  1218. ClassDB::bind_method(D_METHOD("live_debug_instance_node"), &ScriptEditorDebugger::live_debug_instance_node);
  1219. ClassDB::bind_method(D_METHOD("live_debug_remove_node"), &ScriptEditorDebugger::live_debug_remove_node);
  1220. ClassDB::bind_method(D_METHOD("live_debug_remove_and_keep_node"), &ScriptEditorDebugger::live_debug_remove_and_keep_node);
  1221. ClassDB::bind_method(D_METHOD("live_debug_restore_node"), &ScriptEditorDebugger::live_debug_restore_node);
  1222. ClassDB::bind_method(D_METHOD("live_debug_duplicate_node"), &ScriptEditorDebugger::live_debug_duplicate_node);
  1223. ClassDB::bind_method(D_METHOD("live_debug_reparent_node"), &ScriptEditorDebugger::live_debug_reparent_node);
  1224. ClassDB::bind_method(D_METHOD("_scene_tree_property_select_object"), &ScriptEditorDebugger::_scene_tree_property_select_object);
  1225. ClassDB::bind_method(D_METHOD("_scene_tree_property_value_edited"), &ScriptEditorDebugger::_scene_tree_property_value_edited);
  1226. ADD_SIGNAL(MethodInfo("goto_script_line"));
  1227. ADD_SIGNAL(MethodInfo("breaked", PropertyInfo(Variant::BOOL, "reallydid"), PropertyInfo(Variant::BOOL, "can_debug")));
  1228. ADD_SIGNAL(MethodInfo("show_debugger", PropertyInfo(Variant::BOOL, "reallydid")));
  1229. }
  1230. ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
  1231. ppeer = Ref<PacketPeerStream>(memnew(PacketPeerStream));
  1232. ppeer->set_input_buffer_max_size(1024 * 1024 * 8); //8mb should be enough
  1233. editor = p_editor;
  1234. tabs = memnew(TabContainer);
  1235. tabs->set_tab_align(TabContainer::ALIGN_LEFT);
  1236. tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
  1237. tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles"));
  1238. tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles"));
  1239. tabs->set_v_size_flags(SIZE_EXPAND_FILL);
  1240. tabs->set_area_as_parent_rect();
  1241. add_child(tabs);
  1242. { //debugger
  1243. VBoxContainer *vbc = memnew(VBoxContainer);
  1244. vbc->set_name(TTR("Debugger"));
  1245. //tabs->add_child(vbc);
  1246. Control *dbg = vbc;
  1247. HBoxContainer *hbc = memnew(HBoxContainer);
  1248. vbc->add_child(hbc);
  1249. reason = memnew(Label);
  1250. reason->set_text("");
  1251. hbc->add_child(reason);
  1252. reason->set_h_size_flags(SIZE_EXPAND_FILL);
  1253. hbc->add_child(memnew(VSeparator));
  1254. step = memnew(ToolButton);
  1255. hbc->add_child(step);
  1256. step->set_tooltip(TTR("Step Into"));
  1257. step->connect("pressed", this, "debug_step");
  1258. next = memnew(ToolButton);
  1259. hbc->add_child(next);
  1260. next->set_tooltip(TTR("Step Over"));
  1261. next->connect("pressed", this, "debug_next");
  1262. hbc->add_child(memnew(VSeparator));
  1263. dobreak = memnew(ToolButton);
  1264. hbc->add_child(dobreak);
  1265. dobreak->set_tooltip(TTR("Break"));
  1266. dobreak->connect("pressed", this, "debug_break");
  1267. docontinue = memnew(ToolButton);
  1268. hbc->add_child(docontinue);
  1269. docontinue->set_tooltip(TTR("Continue"));
  1270. docontinue->connect("pressed", this, "debug_continue");
  1271. back = memnew(Button);
  1272. hbc->add_child(back);
  1273. back->set_tooltip(TTR("Inspect Previous Instance"));
  1274. back->hide();
  1275. forward = memnew(Button);
  1276. hbc->add_child(forward);
  1277. forward->set_tooltip(TTR("Inspect Next Instance"));
  1278. forward->hide();
  1279. HSplitContainer *sc = memnew(HSplitContainer);
  1280. vbc->add_child(sc);
  1281. sc->set_v_size_flags(SIZE_EXPAND_FILL);
  1282. stack_dump = memnew(Tree);
  1283. stack_dump->set_columns(1);
  1284. stack_dump->set_column_titles_visible(true);
  1285. stack_dump->set_column_title(0, TTR("Stack Frames"));
  1286. stack_dump->set_h_size_flags(SIZE_EXPAND_FILL);
  1287. stack_dump->set_hide_root(true);
  1288. stack_dump->connect("cell_selected", this, "_stack_dump_frame_selected");
  1289. sc->add_child(stack_dump);
  1290. inspector = memnew(PropertyEditor);
  1291. inspector->set_h_size_flags(SIZE_EXPAND_FILL);
  1292. inspector->hide_top_label();
  1293. inspector->get_scene_tree()->set_column_title(0, TTR("Variable"));
  1294. inspector->set_enable_capitalize_paths(false);
  1295. inspector->set_read_only(true);
  1296. inspector->connect("object_id_selected", this, "_scene_tree_property_select_object");
  1297. sc->add_child(inspector);
  1298. server = TCP_Server::create_ref();
  1299. pending_in_queue = 0;
  1300. variables = memnew(ScriptEditorDebuggerVariables);
  1301. breaked = false;
  1302. tabs->add_child(dbg);
  1303. }
  1304. { //errors
  1305. error_split = memnew(HSplitContainer);
  1306. VBoxContainer *errvb = memnew(VBoxContainer);
  1307. errvb->set_h_size_flags(SIZE_EXPAND_FILL);
  1308. error_list = memnew(ItemList);
  1309. errvb->add_margin_child(TTR("Errors:"), error_list, true);
  1310. error_split->add_child(errvb);
  1311. errvb = memnew(VBoxContainer);
  1312. errvb->set_h_size_flags(SIZE_EXPAND_FILL);
  1313. error_stack = memnew(ItemList);
  1314. errvb->add_margin_child(TTR("Stack Trace (if applicable):"), error_stack, true);
  1315. error_split->add_child(errvb);
  1316. error_split->set_name(TTR("Errors"));
  1317. tabs->add_child(error_split);
  1318. }
  1319. { // inquire
  1320. inspect_info = memnew(HSplitContainer);
  1321. inspect_info->set_name(TTR("Remote Inspector"));
  1322. tabs->add_child(inspect_info);
  1323. VBoxContainer *info_left = memnew(VBoxContainer);
  1324. info_left->set_h_size_flags(SIZE_EXPAND_FILL);
  1325. inspect_info->add_child(info_left);
  1326. inspect_scene_tree = memnew(Tree);
  1327. info_left->add_margin_child(TTR("Live Scene Tree:"), inspect_scene_tree, true);
  1328. inspect_scene_tree->connect("cell_selected", this, "_scene_tree_selected");
  1329. inspect_scene_tree->connect("item_collapsed", this, "_scene_tree_folded");
  1330. //
  1331. VBoxContainer *info_right = memnew(VBoxContainer);
  1332. info_right->set_h_size_flags(SIZE_EXPAND_FILL);
  1333. inspect_info->add_child(info_right);
  1334. inspect_properties = memnew(PropertyEditor);
  1335. inspect_properties->hide_top_label();
  1336. inspect_properties->set_show_categories(true);
  1337. inspect_properties->connect("object_id_selected", this, "_scene_tree_property_select_object");
  1338. info_right->add_margin_child(TTR("Remote Object Properties: "), inspect_properties, true);
  1339. inspect_scene_tree_timeout = EDITOR_DEF("debugger/scene_tree_refresh_interval", 1.0);
  1340. inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2);
  1341. inspected_object_id = 0;
  1342. updating_scene_tree = false;
  1343. inspected_object = memnew(ScriptEditorDebuggerInspectedObject);
  1344. inspected_object->connect("value_edited", this, "_scene_tree_property_value_edited");
  1345. }
  1346. { //profiler
  1347. profiler = memnew(EditorProfiler);
  1348. profiler->set_name(TTR("Profiler"));
  1349. tabs->add_child(profiler);
  1350. profiler->connect("enable_profiling", this, "_profiler_activate");
  1351. profiler->connect("break_request", this, "_profiler_seeked");
  1352. }
  1353. { //monitors
  1354. HSplitContainer *hsp = memnew(HSplitContainer);
  1355. perf_monitors = memnew(Tree);
  1356. perf_monitors->set_columns(2);
  1357. perf_monitors->set_column_title(0, TTR("Monitor"));
  1358. perf_monitors->set_column_title(1, TTR("Value"));
  1359. perf_monitors->set_column_titles_visible(true);
  1360. hsp->add_child(perf_monitors);
  1361. perf_monitors->set_select_mode(Tree::SELECT_MULTI);
  1362. perf_monitors->connect("multi_selected", this, "_performance_select");
  1363. perf_draw = memnew(Control);
  1364. perf_draw->connect("draw", this, "_performance_draw");
  1365. hsp->add_child(perf_draw);
  1366. hsp->set_name(TTR("Monitors"));
  1367. hsp->set_split_offset(300);
  1368. tabs->add_child(hsp);
  1369. perf_max.resize(Performance::MONITOR_MAX);
  1370. Map<String, TreeItem *> bases;
  1371. TreeItem *root = perf_monitors->create_item();
  1372. perf_monitors->set_hide_root(true);
  1373. for (int i = 0; i < Performance::MONITOR_MAX; i++) {
  1374. String n = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
  1375. String base = n.get_slice("/", 0);
  1376. String name = n.get_slice("/", 1);
  1377. if (!bases.has(base)) {
  1378. TreeItem *b = perf_monitors->create_item(root);
  1379. b->set_text(0, base.capitalize());
  1380. b->set_editable(0, false);
  1381. b->set_selectable(0, false);
  1382. bases[base] = b;
  1383. }
  1384. TreeItem *it = perf_monitors->create_item(bases[base]);
  1385. it->set_editable(0, false);
  1386. it->set_selectable(0, true);
  1387. it->set_text(0, name.capitalize());
  1388. perf_items.push_back(it);
  1389. perf_max[i] = 0;
  1390. }
  1391. }
  1392. { //vmem inspect
  1393. VBoxContainer *vmem_vb = memnew(VBoxContainer);
  1394. HBoxContainer *vmem_hb = memnew(HBoxContainer);
  1395. Label *vmlb = memnew(Label(TTR("List of Video Memory Usage by Resource:") + " "));
  1396. vmlb->set_h_size_flags(SIZE_EXPAND_FILL);
  1397. vmem_hb->add_child(vmlb);
  1398. vmem_hb->add_child(memnew(Label(TTR("Total:") + " ")));
  1399. vmem_total = memnew(LineEdit);
  1400. vmem_total->set_editable(false);
  1401. vmem_total->set_custom_minimum_size(Size2(100, 1) * EDSCALE);
  1402. vmem_hb->add_child(vmem_total);
  1403. vmem_refresh = memnew(ToolButton);
  1404. vmem_hb->add_child(vmem_refresh);
  1405. vmem_vb->add_child(vmem_hb);
  1406. vmem_refresh->connect("pressed", this, "_video_mem_request");
  1407. VBoxContainer *vmmc = memnew(VBoxContainer);
  1408. vmem_tree = memnew(Tree);
  1409. vmem_tree->set_v_size_flags(SIZE_EXPAND_FILL);
  1410. vmem_tree->set_h_size_flags(SIZE_EXPAND_FILL);
  1411. vmmc->add_child(vmem_tree);
  1412. vmmc->set_v_size_flags(SIZE_EXPAND_FILL);
  1413. vmem_vb->add_child(vmmc);
  1414. vmem_vb->set_name(TTR("Video Mem"));
  1415. vmem_tree->set_columns(4);
  1416. vmem_tree->set_column_titles_visible(true);
  1417. vmem_tree->set_column_title(0, TTR("Resource Path"));
  1418. vmem_tree->set_column_expand(0, true);
  1419. vmem_tree->set_column_expand(1, false);
  1420. vmem_tree->set_column_title(1, TTR("Type"));
  1421. vmem_tree->set_column_min_width(1, 100);
  1422. vmem_tree->set_column_expand(2, false);
  1423. vmem_tree->set_column_title(2, TTR("Format"));
  1424. vmem_tree->set_column_min_width(2, 150);
  1425. vmem_tree->set_column_expand(3, false);
  1426. vmem_tree->set_column_title(3, TTR("Usage"));
  1427. vmem_tree->set_column_min_width(3, 80);
  1428. vmem_tree->set_hide_root(true);
  1429. tabs->add_child(vmem_vb);
  1430. }
  1431. { // misc
  1432. GridContainer *info_left = memnew(GridContainer);
  1433. info_left->set_columns(2);
  1434. info_left->set_name(TTR("Misc"));
  1435. tabs->add_child(info_left);
  1436. clicked_ctrl = memnew(LineEdit);
  1437. clicked_ctrl->set_h_size_flags(SIZE_EXPAND_FILL);
  1438. info_left->add_child(memnew(Label(TTR("Clicked Control:"))));
  1439. info_left->add_child(clicked_ctrl);
  1440. clicked_ctrl_type = memnew(LineEdit);
  1441. info_left->add_child(memnew(Label(TTR("Clicked Control Type:"))));
  1442. info_left->add_child(clicked_ctrl_type);
  1443. live_edit_root = memnew(LineEdit);
  1444. live_edit_root->set_h_size_flags(SIZE_EXPAND_FILL);
  1445. {
  1446. HBoxContainer *lehb = memnew(HBoxContainer);
  1447. Label *l = memnew(Label(TTR("Live Edit Root:")));
  1448. info_left->add_child(l);
  1449. lehb->add_child(live_edit_root);
  1450. le_set = memnew(Button(TTR("Set From Tree")));
  1451. lehb->add_child(le_set);
  1452. le_clear = memnew(Button(TTR("Clear")));
  1453. lehb->add_child(le_clear);
  1454. info_left->add_child(lehb);
  1455. le_set->set_disabled(true);
  1456. le_clear->set_disabled(true);
  1457. }
  1458. }
  1459. msgdialog = memnew(AcceptDialog);
  1460. add_child(msgdialog);
  1461. p_editor->get_undo_redo()->set_method_notify_callback(_method_changeds, this);
  1462. p_editor->get_undo_redo()->set_property_notify_callback(_property_changeds, this);
  1463. live_debug = false;
  1464. last_path_id = false;
  1465. error_count = 0;
  1466. hide_on_stop = true;
  1467. enable_external_editor = false;
  1468. last_error_count = 0;
  1469. EditorNode::get_singleton()->get_pause_button()->connect("pressed", this, "_paused");
  1470. }
  1471. ScriptEditorDebugger::~ScriptEditorDebugger() {
  1472. //inspector->edit(NULL);
  1473. memdelete(variables);
  1474. ppeer->set_stream_peer(Ref<StreamPeer>());
  1475. server->stop();
  1476. memdelete(inspected_object);
  1477. }