script_editor_debugger.cpp 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901
  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. TreeItem *cti = it->get_parent(); //ensure selected is always uncollapsed
  292. while (cti) {
  293. cti->set_collapsed(false);
  294. cti = cti->get_parent();
  295. }
  296. it->select(0);
  297. }
  298. if (p) {
  299. if (!unfold_cache.has(id)) {
  300. it->set_collapsed(true);
  301. }
  302. } else {
  303. if (unfold_cache.has(id)) { //reverse for root
  304. it->set_collapsed(true);
  305. }
  306. }
  307. lv[level] = it;
  308. }
  309. updating_scene_tree = false;
  310. le_clear->set_disabled(false);
  311. le_set->set_disabled(false);
  312. } else if (p_msg == "message:inspect_object") {
  313. ObjectID id = p_data[0];
  314. String type = p_data[1];
  315. Variant path = p_data[2]; //what to do yet, i don't know
  316. int prop_count = p_data[3];
  317. int idx = 4;
  318. if (inspected_object->last_edited_id != id) {
  319. inspected_object->prop_list.clear();
  320. inspected_object->prop_values.clear();
  321. }
  322. for (int i = 0; i < prop_count; i++) {
  323. PropertyInfo pinfo;
  324. pinfo.name = p_data[idx++];
  325. pinfo.type = Variant::Type(int(p_data[idx++]));
  326. pinfo.hint = PropertyHint(int(p_data[idx++]));
  327. pinfo.hint_string = p_data[idx++];
  328. if (pinfo.name.begins_with("*")) {
  329. pinfo.name = pinfo.name.substr(1, pinfo.name.length());
  330. pinfo.usage = PROPERTY_USAGE_CATEGORY;
  331. } else {
  332. pinfo.usage = PROPERTY_USAGE_EDITOR;
  333. }
  334. if (inspected_object->last_edited_id != id) {
  335. //don't update.. it's the same, instead refresh
  336. inspected_object->prop_list.push_back(pinfo);
  337. }
  338. inspected_object->prop_values[pinfo.name] = p_data[idx++];
  339. if (inspected_object->last_edited_id == id) {
  340. //same, just update value, don't rebuild
  341. inspected_object->update_single(pinfo.name.ascii().get_data());
  342. }
  343. }
  344. if (inspected_object->last_edited_id != id) {
  345. //only if different
  346. inspected_object->update();
  347. }
  348. inspected_object->last_edited_id = id;
  349. tabs->set_current_tab(inspect_info->get_index());
  350. inspect_properties->edit(inspected_object);
  351. } else if (p_msg == "message:video_mem") {
  352. vmem_tree->clear();
  353. TreeItem *root = vmem_tree->create_item();
  354. int total = 0;
  355. for (int i = 0; i < p_data.size(); i += 4) {
  356. TreeItem *it = vmem_tree->create_item(root);
  357. String type = p_data[i + 1];
  358. int bytes = p_data[i + 3].operator int();
  359. it->set_text(0, p_data[i + 0]); //path
  360. it->set_text(1, type); //type
  361. it->set_text(2, p_data[i + 2]); //type
  362. it->set_text(3, String::humanize_size(bytes)); //type
  363. total += bytes;
  364. if (has_icon(type, "EditorIcons"))
  365. it->set_icon(0, get_icon(type, "EditorIcons"));
  366. }
  367. vmem_total->set_tooltip(TTR("Bytes:") + " " + itos(total));
  368. vmem_total->set_text(String::humanize_size(total));
  369. } else if (p_msg == "stack_dump") {
  370. stack_dump->clear();
  371. TreeItem *r = stack_dump->create_item();
  372. for (int i = 0; i < p_data.size(); i++) {
  373. Dictionary d = p_data[i];
  374. ERR_CONTINUE(!d.has("function"));
  375. ERR_CONTINUE(!d.has("file"));
  376. ERR_CONTINUE(!d.has("line"));
  377. ERR_CONTINUE(!d.has("id"));
  378. TreeItem *s = stack_dump->create_item(r);
  379. d["frame"] = i;
  380. s->set_metadata(0, d);
  381. //String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"])+" - at func: "+d["function"];
  382. String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]);
  383. s->set_text(0, line);
  384. if (i == 0)
  385. s->select(0);
  386. }
  387. } else if (p_msg == "stack_frame_vars") {
  388. variables->clear();
  389. int ofs = 0;
  390. int mcount = p_data[ofs];
  391. ofs++;
  392. for (int i = 0; i < mcount; i++) {
  393. String n = p_data[ofs + i * 2 + 0];
  394. Variant v = p_data[ofs + i * 2 + 1];
  395. PropertyHint h = PROPERTY_HINT_NONE;
  396. String hs = String();
  397. if (n.begins_with("*")) {
  398. n = n.substr(1, n.length());
  399. h = PROPERTY_HINT_OBJECT_ID;
  400. String s = v;
  401. s = s.replace("[", "");
  402. hs = s.get_slice(":", 0);
  403. v = s.get_slice(":", 1).to_int();
  404. }
  405. variables->add_property("members/" + n, v, h, hs);
  406. }
  407. ofs += mcount * 2;
  408. mcount = p_data[ofs];
  409. ofs++;
  410. for (int i = 0; i < mcount; i++) {
  411. String n = p_data[ofs + i * 2 + 0];
  412. Variant v = p_data[ofs + i * 2 + 1];
  413. PropertyHint h = PROPERTY_HINT_NONE;
  414. String hs = String();
  415. if (n.begins_with("*")) {
  416. n = n.substr(1, n.length());
  417. h = PROPERTY_HINT_OBJECT_ID;
  418. String s = v;
  419. s = s.replace("[", "");
  420. hs = s.get_slice(":", 0);
  421. v = s.get_slice(":", 1).to_int();
  422. }
  423. variables->add_property("locals/" + n, v, h, hs);
  424. }
  425. variables->update();
  426. inspector->edit(variables);
  427. } else if (p_msg == "output") {
  428. //OUT
  429. for (int i = 0; i < p_data.size(); i++) {
  430. String t = p_data[i];
  431. //LOG
  432. if (!EditorNode::get_log()->is_visible()) {
  433. if (EditorNode::get_singleton()->are_bottom_panels_hidden()) {
  434. EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log());
  435. }
  436. }
  437. EditorNode::get_log()->add_message(t);
  438. }
  439. } else if (p_msg == "performance") {
  440. Array arr = p_data[0];
  441. Vector<float> p;
  442. p.resize(arr.size());
  443. for (int i = 0; i < arr.size(); i++) {
  444. p[i] = arr[i];
  445. if (i < perf_items.size()) {
  446. perf_items[i]->set_text(1, rtos(p[i]));
  447. if (p[i] > perf_max[i])
  448. perf_max[i] = p[i];
  449. }
  450. }
  451. perf_history.push_front(p);
  452. perf_draw->update();
  453. } else if (p_msg == "error") {
  454. Array err = p_data[0];
  455. Array vals;
  456. vals.push_back(err[0]);
  457. vals.push_back(err[1]);
  458. vals.push_back(err[2]);
  459. vals.push_back(err[3]);
  460. bool warning = err[9];
  461. bool e;
  462. String time = String("%d:%02d:%02d:%04d").sprintf(vals, &e);
  463. String txt = time + " - " + (err[8].is_zero() ? String(err[7]) : String(err[8]));
  464. String tooltip = TTR("Type:") + String(warning ? TTR("Warning") : TTR("Error"));
  465. tooltip += "\n" + TTR("Description:") + " " + String(err[8]);
  466. tooltip += "\n" + TTR("Time:") + " " + time;
  467. tooltip += "\nC " + TTR("Error:") + " " + String(err[7]);
  468. tooltip += "\nC " + TTR("Source:") + " " + String(err[5]) + ":" + String(err[6]);
  469. tooltip += "\nC " + TTR("Function:") + " " + String(err[4]);
  470. error_list->add_item(txt, EditorNode::get_singleton()->get_gui_base()->get_icon(warning ? "Warning" : "Error", "EditorIcons"));
  471. error_list->set_item_tooltip(error_list->get_item_count() - 1, tooltip);
  472. int scc = p_data[1];
  473. Array stack;
  474. stack.resize(scc);
  475. for (int i = 0; i < scc; i++) {
  476. stack[i] = p_data[2 + i];
  477. }
  478. error_list->set_item_metadata(error_list->get_item_count() - 1, stack);
  479. error_count++;
  480. /*
  481. int count = p_data[1];
  482. Array cstack;
  483. OutputError oe = errors.front()->get();
  484. packet_peer_stream->put_var(oe.hr);
  485. packet_peer_stream->put_var(oe.min);
  486. packet_peer_stream->put_var(oe.sec);
  487. packet_peer_stream->put_var(oe.msec);
  488. packet_peer_stream->put_var(oe.source_func);
  489. packet_peer_stream->put_var(oe.source_file);
  490. packet_peer_stream->put_var(oe.source_line);
  491. packet_peer_stream->put_var(oe.error);
  492. packet_peer_stream->put_var(oe.error_descr);
  493. packet_peer_stream->put_var(oe.warning);
  494. packet_peer_stream->put_var(oe.callstack);
  495. */
  496. } else if (p_msg == "profile_sig") {
  497. //cache a signature
  498. profiler_signature[p_data[1]] = p_data[0];
  499. } else if (p_msg == "profile_frame" || p_msg == "profile_total") {
  500. EditorProfiler::Metric metric;
  501. metric.valid = true;
  502. metric.frame_number = p_data[0];
  503. metric.frame_time = p_data[1];
  504. metric.idle_time = p_data[2];
  505. metric.fixed_time = p_data[3];
  506. metric.fixed_frame_time = p_data[4];
  507. int frame_data_amount = p_data[6];
  508. int frame_function_amount = p_data[7];
  509. if (frame_data_amount) {
  510. EditorProfiler::Metric::Category frame_time;
  511. frame_time.signature = "category_frame_time";
  512. frame_time.name = "Frame Time";
  513. frame_time.total_time = metric.frame_time;
  514. EditorProfiler::Metric::Category::Item item;
  515. item.calls = 1;
  516. item.line = 0;
  517. item.name = "Fixed Time";
  518. item.total = metric.fixed_time;
  519. item.self = item.total;
  520. item.signature = "fixed_time";
  521. frame_time.items.push_back(item);
  522. item.name = "Idle Time";
  523. item.total = metric.idle_time;
  524. item.self = item.total;
  525. item.signature = "idle_time";
  526. frame_time.items.push_back(item);
  527. item.name = "Fixed Frame Time";
  528. item.total = metric.fixed_frame_time;
  529. item.self = item.total;
  530. item.signature = "fixed_frame_time";
  531. frame_time.items.push_back(item);
  532. metric.categories.push_back(frame_time);
  533. }
  534. int idx = 8;
  535. for (int i = 0; i < frame_data_amount; i++) {
  536. EditorProfiler::Metric::Category c;
  537. String name = p_data[idx++];
  538. Array values = p_data[idx++];
  539. c.name = name.capitalize();
  540. c.items.resize(values.size() / 2);
  541. c.total_time = 0;
  542. c.signature = "categ::" + name;
  543. for (int i = 0; i < values.size(); i += 2) {
  544. EditorProfiler::Metric::Category::Item item;
  545. item.name = values[i];
  546. item.calls = 1;
  547. item.self = values[i + 1];
  548. item.total = item.self;
  549. item.signature = "categ::" + name + "::" + item.name;
  550. item.name = item.name.capitalize();
  551. c.total_time += item.total;
  552. c.items[i / 2] = item;
  553. }
  554. metric.categories.push_back(c);
  555. }
  556. EditorProfiler::Metric::Category funcs;
  557. funcs.total_time = p_data[5]; //script time
  558. funcs.items.resize(frame_function_amount);
  559. funcs.name = "Script Functions";
  560. funcs.signature = "script_functions";
  561. for (int i = 0; i < frame_function_amount; i++) {
  562. int signature = p_data[idx++];
  563. int calls = p_data[idx++];
  564. float total = p_data[idx++];
  565. float self = p_data[idx++];
  566. EditorProfiler::Metric::Category::Item item;
  567. if (profiler_signature.has(signature)) {
  568. item.signature = profiler_signature[signature];
  569. String name = profiler_signature[signature];
  570. Vector<String> strings = name.split("::");
  571. if (strings.size() == 3) {
  572. item.name = strings[2];
  573. item.script = strings[0];
  574. item.line = strings[1].to_int();
  575. }
  576. } else {
  577. item.name = "SigErr " + itos(signature);
  578. }
  579. item.calls = calls;
  580. item.self = self;
  581. item.total = total;
  582. funcs.items[i] = item;
  583. }
  584. metric.categories.push_back(funcs);
  585. if (p_msg == "profile_frame")
  586. profiler->add_frame_metric(metric, false);
  587. else
  588. profiler->add_frame_metric(metric, true);
  589. } else if (p_msg == "kill_me") {
  590. editor->call_deferred("stop_child_process");
  591. }
  592. }
  593. void ScriptEditorDebugger::_performance_select(Object *, int, bool) {
  594. perf_draw->update();
  595. }
  596. void ScriptEditorDebugger::_performance_draw() {
  597. Vector<int> which;
  598. for (int i = 0; i < perf_items.size(); i++) {
  599. if (perf_items[i]->is_selected(0))
  600. which.push_back(i);
  601. }
  602. if (which.empty())
  603. return;
  604. Ref<StyleBox> graph_sb = get_stylebox("normal", "TextEdit");
  605. Ref<Font> graph_font = get_font("font", "TextEdit");
  606. int cols = Math::ceil(Math::sqrt((float)which.size()));
  607. int rows = (which.size() + 1) / cols;
  608. if (which.size() == 1)
  609. rows = 1;
  610. int margin = 3;
  611. int point_sep = 5;
  612. Size2i s = Size2i(perf_draw->get_size()) / Size2i(cols, rows);
  613. for (int i = 0; i < which.size(); i++) {
  614. Point2i p(i % cols, i / cols);
  615. Rect2i r(p * s, s);
  616. r.position += Point2(margin, margin);
  617. r.size -= Point2(margin, margin) * 2.0;
  618. perf_draw->draw_style_box(graph_sb, r);
  619. r.position += graph_sb->get_offset();
  620. r.size -= graph_sb->get_minimum_size();
  621. int pi = which[i];
  622. Color c = get_color("success_color", "Editor");
  623. c.set_hsv(Math::fmod(c.get_h() + pi * 0.7654, 1), c.get_s(), c.get_v());
  624. //c = c.linear_interpolate(get_color("base_color", "Editor"), 0.9);
  625. c.a = 0.8;
  626. perf_draw->draw_string(graph_font, r.position + Point2(0, graph_font->get_ascent()), perf_items[pi]->get_text(0), c, r.size.x);
  627. c.a = 0.6;
  628. 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);
  629. float spacing = point_sep / float(cols);
  630. float from = r.size.width;
  631. List<Vector<float> >::Element *E = perf_history.front();
  632. float prev = -1;
  633. while (from >= 0 && E) {
  634. float m = perf_max[pi];
  635. if (m == 0)
  636. m = 0.00001;
  637. float h = E->get()[pi] / m;
  638. h = (1.0 - h) * r.size.y;
  639. c.a = 0.7;
  640. if (E != perf_history.front())
  641. perf_draw->draw_line(r.position + Point2(from, h), r.position + Point2(from + spacing, prev), c, 2.0);
  642. prev = h;
  643. E = E->next();
  644. from -= spacing;
  645. }
  646. }
  647. }
  648. void ScriptEditorDebugger::_notification(int p_what) {
  649. switch (p_what) {
  650. case NOTIFICATION_ENTER_TREE: {
  651. inspector->edit(variables);
  652. step->set_icon(get_icon("DebugStep", "EditorIcons"));
  653. next->set_icon(get_icon("DebugNext", "EditorIcons"));
  654. back->set_icon(get_icon("Back", "EditorIcons"));
  655. forward->set_icon(get_icon("Forward", "EditorIcons"));
  656. dobreak->set_icon(get_icon("Pause", "EditorIcons"));
  657. docontinue->set_icon(get_icon("DebugContinue", "EditorIcons"));
  658. //scene_tree_refresh->set_icon( get_icon("Reload","EditorIcons"));
  659. le_set->connect("pressed", this, "_live_edit_set");
  660. le_clear->connect("pressed", this, "_live_edit_clear");
  661. error_list->connect("item_selected", this, "_error_selected");
  662. error_stack->connect("item_selected", this, "_error_stack_selected");
  663. vmem_refresh->set_icon(get_icon("Reload", "EditorIcons"));
  664. reason->add_color_override("font_color", get_color("error_color", "Editor"));
  665. } break;
  666. case NOTIFICATION_PROCESS: {
  667. if (connection.is_valid()) {
  668. inspect_scene_tree_timeout -= get_process_delta_time();
  669. if (inspect_scene_tree_timeout < 0) {
  670. inspect_scene_tree_timeout = EditorSettings::get_singleton()->get("debugger/scene_tree_refresh_interval");
  671. if (inspect_scene_tree->is_visible_in_tree()) {
  672. _scene_tree_request();
  673. if (inspected_object_id != 0) {
  674. //take the chance and re-inspect selected object
  675. Array msg;
  676. msg.push_back("inspect_object");
  677. msg.push_back(inspected_object_id);
  678. ppeer->put_var(msg);
  679. }
  680. }
  681. }
  682. inspect_edited_object_timeout -= get_process_delta_time();
  683. if (inspect_edited_object_timeout < 0) {
  684. inspect_edited_object_timeout = EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
  685. if (inspect_scene_tree->is_visible_in_tree() && inspected_object_id) {
  686. //take the chance and re-inspect selected object
  687. Array msg;
  688. msg.push_back("inspect_object");
  689. msg.push_back(inspected_object_id);
  690. ppeer->put_var(msg);
  691. }
  692. }
  693. }
  694. if (error_count != last_error_count) {
  695. if (error_count == 0) {
  696. error_split->set_name(TTR("Errors"));
  697. debugger_button->set_text(TTR("Debugger"));
  698. debugger_button->set_icon(Ref<Texture>());
  699. tabs->set_tab_icon(error_split->get_index(), Ref<Texture>());
  700. } else {
  701. error_split->set_name(TTR("Errors") + " (" + itos(error_count) + ")");
  702. debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count) + ")");
  703. debugger_button->set_icon(get_icon("Error", "EditorIcons"));
  704. tabs->set_tab_icon(error_split->get_index(), get_icon("Error", "EditorIcons"));
  705. }
  706. last_error_count = error_count;
  707. }
  708. if (connection.is_null()) {
  709. if (server->is_connection_available()) {
  710. connection = server->take_connection();
  711. if (connection.is_null())
  712. break;
  713. EditorNode::get_log()->add_message("** Debug Process Started **");
  714. ppeer->set_stream_peer(connection);
  715. //EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
  716. //emit_signal("show_debugger",true);
  717. dobreak->set_disabled(false);
  718. tabs->set_current_tab(0);
  719. reason->set_text(TTR("Child Process Connected"));
  720. reason->set_tooltip(TTR("Child Process Connected"));
  721. profiler->clear();
  722. inspect_scene_tree->clear();
  723. le_set->set_disabled(true);
  724. le_clear->set_disabled(false);
  725. error_list->clear();
  726. error_stack->clear();
  727. error_count = 0;
  728. profiler_signature.clear();
  729. //live_edit_root->set_text("/root");
  730. EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
  731. EditorNode::get_singleton()->get_pause_button()->set_disabled(false);
  732. update_live_edit_root();
  733. if (profiler->is_profiling()) {
  734. _profiler_activate(true);
  735. }
  736. } else {
  737. break;
  738. }
  739. };
  740. if (!connection->is_connected_to_host()) {
  741. stop();
  742. editor->notify_child_process_exited(); //somehow, exited
  743. break;
  744. };
  745. if (ppeer->get_available_packet_count() <= 0) {
  746. break;
  747. };
  748. while (ppeer->get_available_packet_count() > 0) {
  749. if (pending_in_queue) {
  750. int todo = MIN(ppeer->get_available_packet_count(), pending_in_queue);
  751. for (int i = 0; i < todo; i++) {
  752. Variant cmd;
  753. Error ret = ppeer->get_var(cmd);
  754. if (ret != OK) {
  755. stop();
  756. ERR_FAIL_COND(ret != OK);
  757. }
  758. message.push_back(cmd);
  759. pending_in_queue--;
  760. }
  761. if (pending_in_queue == 0) {
  762. _parse_message(message_type, message);
  763. message.clear();
  764. }
  765. } else {
  766. if (ppeer->get_available_packet_count() >= 2) {
  767. Variant cmd;
  768. Error ret = ppeer->get_var(cmd);
  769. if (ret != OK) {
  770. stop();
  771. ERR_FAIL_COND(ret != OK);
  772. }
  773. if (cmd.get_type() != Variant::STRING) {
  774. stop();
  775. ERR_FAIL_COND(cmd.get_type() != Variant::STRING);
  776. }
  777. message_type = cmd;
  778. //print_line("GOT: "+message_type);
  779. ret = ppeer->get_var(cmd);
  780. if (ret != OK) {
  781. stop();
  782. ERR_FAIL_COND(ret != OK);
  783. }
  784. if (cmd.get_type() != Variant::INT) {
  785. stop();
  786. ERR_FAIL_COND(cmd.get_type() != Variant::INT);
  787. }
  788. pending_in_queue = cmd;
  789. if (pending_in_queue == 0) {
  790. _parse_message(message_type, Array());
  791. message.clear();
  792. }
  793. } else {
  794. break;
  795. }
  796. }
  797. }
  798. } break;
  799. case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
  800. tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles"));
  801. tabs->add_style_override("tab_fg", editor->get_gui_base()->get_stylebox("DebuggerTabFG", "EditorStyles"));
  802. tabs->add_style_override("tab_bg", editor->get_gui_base()->get_stylebox("DebuggerTabBG", "EditorStyles"));
  803. } break;
  804. }
  805. }
  806. void ScriptEditorDebugger::start() {
  807. stop();
  808. if (is_visible_in_tree()) {
  809. EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
  810. }
  811. perf_history.clear();
  812. for (int i = 0; i < Performance::MONITOR_MAX; i++) {
  813. perf_max[i] = 0;
  814. }
  815. int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
  816. if (server->listen(remote_port) != OK) {
  817. EditorNode::get_log()->add_message(String("** Error listening on port ") + itos(remote_port) + String(" **"));
  818. return;
  819. }
  820. set_process(true);
  821. }
  822. void ScriptEditorDebugger::pause() {
  823. }
  824. void ScriptEditorDebugger::unpause() {
  825. }
  826. void ScriptEditorDebugger::stop() {
  827. set_process(false);
  828. server->stop();
  829. ppeer->set_stream_peer(Ref<StreamPeer>());
  830. if (connection.is_valid()) {
  831. EditorNode::get_log()->add_message("** Debug Process Stopped **");
  832. connection.unref();
  833. }
  834. pending_in_queue = 0;
  835. message.clear();
  836. node_path_cache.clear();
  837. res_path_cache.clear();
  838. profiler_signature.clear();
  839. le_clear->set_disabled(false);
  840. le_set->set_disabled(true);
  841. profiler->set_enabled(true);
  842. inspect_properties->edit(NULL);
  843. inspect_scene_tree->clear();
  844. EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
  845. EditorNode::get_singleton()->get_pause_button()->set_disabled(true);
  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. }