script_editor_debugger.cpp 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899
  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. editor = p_editor;
  1233. tabs = memnew(TabContainer);
  1234. tabs->set_tab_align(TabContainer::ALIGN_LEFT);
  1235. tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
  1236. tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles"));
  1237. tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles"));
  1238. tabs->set_v_size_flags(SIZE_EXPAND_FILL);
  1239. tabs->set_area_as_parent_rect();
  1240. add_child(tabs);
  1241. { //debugger
  1242. VBoxContainer *vbc = memnew(VBoxContainer);
  1243. vbc->set_name(TTR("Debugger"));
  1244. //tabs->add_child(vbc);
  1245. Control *dbg = vbc;
  1246. HBoxContainer *hbc = memnew(HBoxContainer);
  1247. vbc->add_child(hbc);
  1248. reason = memnew(Label);
  1249. reason->set_text("");
  1250. hbc->add_child(reason);
  1251. reason->set_h_size_flags(SIZE_EXPAND_FILL);
  1252. hbc->add_child(memnew(VSeparator));
  1253. step = memnew(ToolButton);
  1254. hbc->add_child(step);
  1255. step->set_tooltip(TTR("Step Into"));
  1256. step->connect("pressed", this, "debug_step");
  1257. next = memnew(ToolButton);
  1258. hbc->add_child(next);
  1259. next->set_tooltip(TTR("Step Over"));
  1260. next->connect("pressed", this, "debug_next");
  1261. hbc->add_child(memnew(VSeparator));
  1262. dobreak = memnew(ToolButton);
  1263. hbc->add_child(dobreak);
  1264. dobreak->set_tooltip(TTR("Break"));
  1265. dobreak->connect("pressed", this, "debug_break");
  1266. docontinue = memnew(ToolButton);
  1267. hbc->add_child(docontinue);
  1268. docontinue->set_tooltip(TTR("Continue"));
  1269. docontinue->connect("pressed", this, "debug_continue");
  1270. back = memnew(Button);
  1271. hbc->add_child(back);
  1272. back->set_tooltip(TTR("Inspect Previous Instance"));
  1273. back->hide();
  1274. forward = memnew(Button);
  1275. hbc->add_child(forward);
  1276. forward->set_tooltip(TTR("Inspect Next Instance"));
  1277. forward->hide();
  1278. HSplitContainer *sc = memnew(HSplitContainer);
  1279. vbc->add_child(sc);
  1280. sc->set_v_size_flags(SIZE_EXPAND_FILL);
  1281. stack_dump = memnew(Tree);
  1282. stack_dump->set_columns(1);
  1283. stack_dump->set_column_titles_visible(true);
  1284. stack_dump->set_column_title(0, TTR("Stack Frames"));
  1285. stack_dump->set_h_size_flags(SIZE_EXPAND_FILL);
  1286. stack_dump->set_hide_root(true);
  1287. stack_dump->connect("cell_selected", this, "_stack_dump_frame_selected");
  1288. sc->add_child(stack_dump);
  1289. inspector = memnew(PropertyEditor);
  1290. inspector->set_h_size_flags(SIZE_EXPAND_FILL);
  1291. inspector->hide_top_label();
  1292. inspector->get_scene_tree()->set_column_title(0, TTR("Variable"));
  1293. inspector->set_enable_capitalize_paths(false);
  1294. inspector->set_read_only(true);
  1295. inspector->connect("object_id_selected", this, "_scene_tree_property_select_object");
  1296. sc->add_child(inspector);
  1297. server = TCP_Server::create_ref();
  1298. pending_in_queue = 0;
  1299. variables = memnew(ScriptEditorDebuggerVariables);
  1300. breaked = false;
  1301. tabs->add_child(dbg);
  1302. }
  1303. { //errors
  1304. error_split = memnew(HSplitContainer);
  1305. VBoxContainer *errvb = memnew(VBoxContainer);
  1306. errvb->set_h_size_flags(SIZE_EXPAND_FILL);
  1307. error_list = memnew(ItemList);
  1308. errvb->add_margin_child(TTR("Errors:"), error_list, true);
  1309. error_split->add_child(errvb);
  1310. errvb = memnew(VBoxContainer);
  1311. errvb->set_h_size_flags(SIZE_EXPAND_FILL);
  1312. error_stack = memnew(ItemList);
  1313. errvb->add_margin_child(TTR("Stack Trace (if applicable):"), error_stack, true);
  1314. error_split->add_child(errvb);
  1315. error_split->set_name(TTR("Errors"));
  1316. tabs->add_child(error_split);
  1317. }
  1318. { // inquire
  1319. inspect_info = memnew(HSplitContainer);
  1320. inspect_info->set_name(TTR("Remote Inspector"));
  1321. tabs->add_child(inspect_info);
  1322. VBoxContainer *info_left = memnew(VBoxContainer);
  1323. info_left->set_h_size_flags(SIZE_EXPAND_FILL);
  1324. inspect_info->add_child(info_left);
  1325. inspect_scene_tree = memnew(Tree);
  1326. info_left->add_margin_child(TTR("Live Scene Tree:"), inspect_scene_tree, true);
  1327. inspect_scene_tree->connect("cell_selected", this, "_scene_tree_selected");
  1328. inspect_scene_tree->connect("item_collapsed", this, "_scene_tree_folded");
  1329. //
  1330. VBoxContainer *info_right = memnew(VBoxContainer);
  1331. info_right->set_h_size_flags(SIZE_EXPAND_FILL);
  1332. inspect_info->add_child(info_right);
  1333. inspect_properties = memnew(PropertyEditor);
  1334. inspect_properties->hide_top_label();
  1335. inspect_properties->set_show_categories(true);
  1336. inspect_properties->connect("object_id_selected", this, "_scene_tree_property_select_object");
  1337. info_right->add_margin_child(TTR("Remote Object Properties: "), inspect_properties, true);
  1338. inspect_scene_tree_timeout = EDITOR_DEF("debugger/scene_tree_refresh_interval", 1.0);
  1339. inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2);
  1340. inspected_object_id = 0;
  1341. updating_scene_tree = false;
  1342. inspected_object = memnew(ScriptEditorDebuggerInspectedObject);
  1343. inspected_object->connect("value_edited", this, "_scene_tree_property_value_edited");
  1344. }
  1345. { //profiler
  1346. profiler = memnew(EditorProfiler);
  1347. profiler->set_name(TTR("Profiler"));
  1348. tabs->add_child(profiler);
  1349. profiler->connect("enable_profiling", this, "_profiler_activate");
  1350. profiler->connect("break_request", this, "_profiler_seeked");
  1351. }
  1352. { //monitors
  1353. HSplitContainer *hsp = memnew(HSplitContainer);
  1354. perf_monitors = memnew(Tree);
  1355. perf_monitors->set_columns(2);
  1356. perf_monitors->set_column_title(0, TTR("Monitor"));
  1357. perf_monitors->set_column_title(1, TTR("Value"));
  1358. perf_monitors->set_column_titles_visible(true);
  1359. hsp->add_child(perf_monitors);
  1360. perf_monitors->set_select_mode(Tree::SELECT_MULTI);
  1361. perf_monitors->connect("multi_selected", this, "_performance_select");
  1362. perf_draw = memnew(Control);
  1363. perf_draw->connect("draw", this, "_performance_draw");
  1364. hsp->add_child(perf_draw);
  1365. hsp->set_name(TTR("Monitors"));
  1366. hsp->set_split_offset(300);
  1367. tabs->add_child(hsp);
  1368. perf_max.resize(Performance::MONITOR_MAX);
  1369. Map<String, TreeItem *> bases;
  1370. TreeItem *root = perf_monitors->create_item();
  1371. perf_monitors->set_hide_root(true);
  1372. for (int i = 0; i < Performance::MONITOR_MAX; i++) {
  1373. String n = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
  1374. String base = n.get_slice("/", 0);
  1375. String name = n.get_slice("/", 1);
  1376. if (!bases.has(base)) {
  1377. TreeItem *b = perf_monitors->create_item(root);
  1378. b->set_text(0, base.capitalize());
  1379. b->set_editable(0, false);
  1380. b->set_selectable(0, false);
  1381. bases[base] = b;
  1382. }
  1383. TreeItem *it = perf_monitors->create_item(bases[base]);
  1384. it->set_editable(0, false);
  1385. it->set_selectable(0, true);
  1386. it->set_text(0, name.capitalize());
  1387. perf_items.push_back(it);
  1388. perf_max[i] = 0;
  1389. }
  1390. }
  1391. { //vmem inspect
  1392. VBoxContainer *vmem_vb = memnew(VBoxContainer);
  1393. HBoxContainer *vmem_hb = memnew(HBoxContainer);
  1394. Label *vmlb = memnew(Label(TTR("List of Video Memory Usage by Resource:") + " "));
  1395. vmlb->set_h_size_flags(SIZE_EXPAND_FILL);
  1396. vmem_hb->add_child(vmlb);
  1397. vmem_hb->add_child(memnew(Label(TTR("Total:") + " ")));
  1398. vmem_total = memnew(LineEdit);
  1399. vmem_total->set_editable(false);
  1400. vmem_total->set_custom_minimum_size(Size2(100, 1) * EDSCALE);
  1401. vmem_hb->add_child(vmem_total);
  1402. vmem_refresh = memnew(ToolButton);
  1403. vmem_hb->add_child(vmem_refresh);
  1404. vmem_vb->add_child(vmem_hb);
  1405. vmem_refresh->connect("pressed", this, "_video_mem_request");
  1406. VBoxContainer *vmmc = memnew(VBoxContainer);
  1407. vmem_tree = memnew(Tree);
  1408. vmem_tree->set_v_size_flags(SIZE_EXPAND_FILL);
  1409. vmem_tree->set_h_size_flags(SIZE_EXPAND_FILL);
  1410. vmmc->add_child(vmem_tree);
  1411. vmmc->set_v_size_flags(SIZE_EXPAND_FILL);
  1412. vmem_vb->add_child(vmmc);
  1413. vmem_vb->set_name(TTR("Video Mem"));
  1414. vmem_tree->set_columns(4);
  1415. vmem_tree->set_column_titles_visible(true);
  1416. vmem_tree->set_column_title(0, TTR("Resource Path"));
  1417. vmem_tree->set_column_expand(0, true);
  1418. vmem_tree->set_column_expand(1, false);
  1419. vmem_tree->set_column_title(1, TTR("Type"));
  1420. vmem_tree->set_column_min_width(1, 100);
  1421. vmem_tree->set_column_expand(2, false);
  1422. vmem_tree->set_column_title(2, TTR("Format"));
  1423. vmem_tree->set_column_min_width(2, 150);
  1424. vmem_tree->set_column_expand(3, false);
  1425. vmem_tree->set_column_title(3, TTR("Usage"));
  1426. vmem_tree->set_column_min_width(3, 80);
  1427. vmem_tree->set_hide_root(true);
  1428. tabs->add_child(vmem_vb);
  1429. }
  1430. { // misc
  1431. GridContainer *info_left = memnew(GridContainer);
  1432. info_left->set_columns(2);
  1433. info_left->set_name(TTR("Misc"));
  1434. tabs->add_child(info_left);
  1435. clicked_ctrl = memnew(LineEdit);
  1436. clicked_ctrl->set_h_size_flags(SIZE_EXPAND_FILL);
  1437. info_left->add_child(memnew(Label(TTR("Clicked Control:"))));
  1438. info_left->add_child(clicked_ctrl);
  1439. clicked_ctrl_type = memnew(LineEdit);
  1440. info_left->add_child(memnew(Label(TTR("Clicked Control Type:"))));
  1441. info_left->add_child(clicked_ctrl_type);
  1442. live_edit_root = memnew(LineEdit);
  1443. live_edit_root->set_h_size_flags(SIZE_EXPAND_FILL);
  1444. {
  1445. HBoxContainer *lehb = memnew(HBoxContainer);
  1446. Label *l = memnew(Label(TTR("Live Edit Root:")));
  1447. info_left->add_child(l);
  1448. lehb->add_child(live_edit_root);
  1449. le_set = memnew(Button(TTR("Set From Tree")));
  1450. lehb->add_child(le_set);
  1451. le_clear = memnew(Button(TTR("Clear")));
  1452. lehb->add_child(le_clear);
  1453. info_left->add_child(lehb);
  1454. le_set->set_disabled(true);
  1455. le_clear->set_disabled(true);
  1456. }
  1457. }
  1458. msgdialog = memnew(AcceptDialog);
  1459. add_child(msgdialog);
  1460. p_editor->get_undo_redo()->set_method_notify_callback(_method_changeds, this);
  1461. p_editor->get_undo_redo()->set_property_notify_callback(_property_changeds, this);
  1462. live_debug = false;
  1463. last_path_id = false;
  1464. error_count = 0;
  1465. hide_on_stop = true;
  1466. enable_external_editor = false;
  1467. last_error_count = 0;
  1468. EditorNode::get_singleton()->get_pause_button()->connect("pressed", this, "_paused");
  1469. }
  1470. ScriptEditorDebugger::~ScriptEditorDebugger() {
  1471. //inspector->edit(NULL);
  1472. memdelete(variables);
  1473. ppeer->set_stream_peer(Ref<StreamPeer>());
  1474. server->stop();
  1475. memdelete(inspected_object);
  1476. }