diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index bd63cadc579..060819b90e6 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1377,120 +1377,125 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) { while(!ea->quit_request) { String adb=EditorSettings::get_singleton()->get("android/adb"); - if (!FileAccess::exists(adb)) { - OS::get_singleton()->delay_usec(3000000); - continue; //adb not configured - } + if (FileAccess::exists(adb)) { - String devices; - List args; - args.push_back("devices"); - int ec; - Error err = OS::get_singleton()->execute(adb,args,true,NULL,&devices,&ec); - Vector ds = devices.split("\n"); - Vector ldevices; - for(int i=1;i args; + args.push_back("devices"); + int ec; + Error err = OS::get_singleton()->execute(adb,args,true,NULL,&devices,&ec); + Vector ds = devices.split("\n"); + Vector ldevices; + for(int i=1;idevice_lock->lock(); - - bool different=false; - - if (devices.size()!=ldevices.size()) { - - different=true; - } else { - - for(int i=0;idevices.size();i++) { - - if (ea->devices[i].id!=ldevices[i]) { - different=true; - break; - } + String d = ds[i]; + int dpos = d.find("device"); + if (dpos==-1) + continue; + d=d.substr(0,dpos).strip_edges(); + // print_line("found devuce: "+d); + ldevices.push_back(d); } - } - if (different) { + ea->device_lock->lock(); + bool different=false; - Vector ndevices; + if (devices.size()!=ldevices.size()) { - for(int i=0;idevices.size();j++) { - if (ea->devices[j].id==ldevices[i]) { - d.description=ea->devices[j].description; - d.name=ea->devices[j].name; + for(int i=0;idevices.size();i++) { + + if (ea->devices[i].id!=ldevices[i]) { + different=true; + break; } } + } - if (d.description=="") { - //in the oven, request! - args.clear(); - args.push_back("-s"); - args.push_back(d.id); - args.push_back("shell"); - args.push_back("cat"); - args.push_back("/system/build.prop"); - int ec; - String dp; + if (different) { - Error err = OS::get_singleton()->execute(adb,args,true,NULL,&dp,&ec); - print_line("RV: "+itos(ec)); - Vector props = dp.split("\n"); - String vendor; - String device; - d.description+"Device ID: "+d.id+"\n"; - for(int j=0;j>16)+"."+itos((opengl>>8)&0xFF)+"."+itos((opengl)&0xFF)+"\n"; + Vector ndevices; + + for(int i=0;idevices.size();j++) { + if (ea->devices[j].id==ldevices[i]) { + d.description=ea->devices[j].description; + d.name=ea->devices[j].name; } } - d.name=vendor+" "+device; -// print_line("name: "+d.name); -// print_line("description: "+d.description); + if (d.description=="") { + //in the oven, request! + args.clear(); + args.push_back("-s"); + args.push_back(d.id); + args.push_back("shell"); + args.push_back("cat"); + args.push_back("/system/build.prop"); + int ec; + String dp; + + Error err = OS::get_singleton()->execute(adb,args,true,NULL,&dp,&ec); + print_line("RV: "+itos(ec)); + Vector props = dp.split("\n"); + String vendor; + String device; + d.description+"Device ID: "+d.id+"\n"; + for(int j=0;j>16)+"."+itos((opengl>>8)&0xFF)+"."+itos((opengl)&0xFF)+"\n"; + } + } + + d.name=vendor+" "+device; + // print_line("name: "+d.name); + // print_line("description: "+d.description); + + } + + ndevices.push_back(d); } - ndevices.push_back(d); - + ea->devices=ndevices; + ea->devices_changed=true; } - ea->devices=ndevices; - ea->devices_changed=true; + ea->device_lock->unlock(); } - ea->device_lock->unlock(); + uint64_t wait = 3000000; + uint64_t time = OS::get_singleton()->get_ticks_usec(); + while(OS::get_singleton()->get_ticks_usec() - time < wait ) { + OS::get_singleton()->delay_usec(1000); + if (ea->quit_request) + break; + } - OS::get_singleton()->delay_usec(3000000); } if (EditorSettings::get_singleton()->get("android/shutdown_adb_on_exit")) { diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp index da3a958a56d..daee5aab9b7 100644 --- a/platform/bb10/export/export.cpp +++ b/platform/bb10/export/export.cpp @@ -532,95 +532,99 @@ void EditorExportPlatformBB10::_device_poll_thread(void *ud) { if (windows) bb_deploy+=".bat"; - if (!FileAccess::exists(bb_deploy)) { - OS::get_singleton()->delay_usec(3000000); - continue; //adb not configured - } + if (FileAccess::exists(bb_deploy)) { - Vector devices; + Vector devices; - for (int i=0;iget("blackberry/device_"+itos(i+1)+"/host"); - if (host==String()) - continue; - String pass = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/password"); - if (pass==String()) - continue; + String host = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/host"); + if (host==String()) + continue; + String pass = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/password"); + if (pass==String()) + continue; - List args; - args.push_back("-listDeviceInfo"); - args.push_back(host); - args.push_back("-password"); - args.push_back(pass); + List args; + args.push_back("-listDeviceInfo"); + args.push_back(host); + args.push_back("-password"); + args.push_back(pass); - int ec; - String dp; + int ec; + String dp; - Error err = OS::get_singleton()->execute(bb_deploy,args,true,NULL,&dp,&ec); + Error err = OS::get_singleton()->execute(bb_deploy,args,true,NULL,&dp,&ec); - if (err==OK && ec==0) { + if (err==OK && ec==0) { - Device dev; - dev.index=i; - String descr; - Vector ls=dp.split("\n"); + Device dev; + dev.index=i; + String descr; + Vector ls=dp.split("\n"); - for(int i=0;idevice_lock->lock(); + ea->device_lock->lock(); - if (ea->devices.size()!=devices.size()) { - changed=true; - } else { + if (ea->devices.size()!=devices.size()) { + changed=true; + } else { - for(int i=0;idevices.size();i++) { + for(int i=0;idevices.size();i++) { - if (ea->devices[i].index!=devices[i].index) { - changed=true; - break; + if (ea->devices[i].index!=devices[i].index) { + changed=true; + break; + } } } + + if (changed) { + + ea->devices=devices; + ea->devices_changed=true; + } + + ea->device_lock->unlock(); } - if (changed) { - ea->devices=devices; - ea->devices_changed=true; + uint64_t wait = 3000000; + uint64_t time = OS::get_singleton()->get_ticks_usec(); + while(OS::get_singleton()->get_ticks_usec() - time < wait ) { + OS::get_singleton()->delay_usec(1000); + if (ea->quit_request) + break; } - - ea->device_lock->unlock(); - - OS::get_singleton()->delay_usec(3000000); - } } diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 29925b62f5b..f8af83e23bb 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -168,11 +168,8 @@ void Node::_propagate_enter_tree() { data.inside_tree=true; - const StringName *K=NULL; - - while ((K=data.grouped.next(K))) { - - data.tree->add_to_group(*K,this); + for (Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) { + E->get().group=data.tree->add_to_group(E->key(),this); } @@ -257,13 +254,13 @@ void Node::_propagate_exit_tree() { data.tree->node_removed(this); // exit groups - const StringName *K=NULL; - while ((K=data.grouped.next(K))) { - - data.tree->remove_from_group(*K,this); + for (Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) { + data.tree->remove_from_group(E->key(),this); + E->get().group=NULL; } + data.viewport = NULL; if (data.tree) @@ -307,6 +304,9 @@ void Node::move_child(Node *p_child,int p_pos) { data.children[i]->notification( NOTIFICATION_MOVED_IN_PARENT ); } + for (const Map< StringName, GroupData>::Element *E=p_child->data.grouped.front();E;E=E->next()) { + E->get().group->changed=true; + } data.blocked--; @@ -1193,8 +1193,12 @@ void Node::add_to_group(const StringName& p_identifier,bool p_persistent) { GroupData gd; - if (data.tree) - data.tree->add_to_group(p_identifier,this); + SceneTree::Group *gptr=NULL; + if (data.tree) { + gd.group=data.tree->add_to_group(p_identifier,this); + } else { + gd.group=NULL; + } gd.persistent=p_persistent; @@ -1207,14 +1211,15 @@ void Node::remove_from_group(const StringName& p_identifier) { ERR_FAIL_COND(!data.grouped.has(p_identifier) ); - GroupData *g=data.grouped.getptr(p_identifier); - ERR_FAIL_COND(!g); + Map< StringName, GroupData>::Element *E=data.grouped.find(p_identifier); + + ERR_FAIL_COND(!E); if (data.tree) - data.tree->remove_from_group(p_identifier,this); + data.tree->remove_from_group(E->key(),this); - data.grouped.erase(p_identifier); + data.grouped.erase(E); } @@ -1232,13 +1237,11 @@ Array Node::_get_groups() const { void Node::get_groups(List *p_groups) const { - const StringName *K=NULL; - - while ((K=data.grouped.next(K))) { + for (const Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) { GroupInfo gi; - gi.name=*K; - gi.persistent=data.grouped[*K].persistent; + gi.name=E->key(); + gi.persistent=E->get().persistent; p_groups->push_back(gi); } @@ -1246,16 +1249,16 @@ void Node::get_groups(List *p_groups) const { bool Node::has_persistent_groups() const { - const StringName *K=NULL; - while ((K=data.grouped.next(K))) { - - if (data.grouped[*K].persistent) + for (const Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) { + if (E->get().persistent) return true; } + return false; + } void Node::_print_tree(const Node *p_node) { diff --git a/scene/main/node.h b/scene/main/node.h index cf62e7cdea9..d099f6e773d 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -64,6 +64,7 @@ private: struct GroupData { bool persistent; + SceneTree::Group *group; GroupData() { persistent=false; } }; @@ -91,7 +92,7 @@ private: Viewport *viewport; - HashMap< StringName, GroupData,StringNameHasher> grouped; + Map< StringName, GroupData> grouped; List::Element *OW; // owned element List owned; diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index d7f22c32280..a7ef7ca7c1c 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -64,7 +64,7 @@ void SceneTree::node_removed(Node *p_node) { } -void SceneTree::add_to_group(const StringName& p_group, Node *p_node) { +SceneTree::Group *SceneTree::add_to_group(const StringName& p_group, Node *p_node) { Map::Element *E=group_map.find(p_group); if (!E) { @@ -73,10 +73,12 @@ void SceneTree::add_to_group(const StringName& p_group, Node *p_node) { if (E->get().nodes.find(p_node)!=-1) { ERR_EXPLAIN("Already in group: "+p_group); - ERR_FAIL(); + ERR_FAIL_V(&E->get()); } E->get().nodes.push_back(p_node); - E->get().last_tree_version=0; + //E->get().last_tree_version=0; + E->get().changed=true; + return &E->get(); } void SceneTree::remove_from_group(const StringName& p_group, Node *p_node) { @@ -125,7 +127,7 @@ void SceneTree::_flush_ugc() { void SceneTree::_update_group_order(Group& g) { - if (g.last_tree_version==tree_version) + if (!g.changed) return; if (g.nodes.empty()) return; @@ -135,7 +137,8 @@ void SceneTree::_update_group_order(Group& g) { SortArray node_sort; node_sort.sort(nodes,node_count); - g.last_tree_version=tree_version; + g.changed=false; + } @@ -148,8 +151,6 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const if (g.nodes.empty()) return; - _update_group_order(g); - if (p_call_flags&GROUP_CALL_UNIQUE && !(p_call_flags&GROUP_CALL_REALTIME)) { @@ -175,6 +176,8 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const return; } + _update_group_order(g); + Vector nodes_copy = g.nodes; Node **nodes = &nodes_copy[0]; int node_count=nodes_copy.size(); diff --git a/scene/main/scene_main_loop.h b/scene/main/scene_main_loop.h index 5fc9e0c1ae4..15604a34609 100644 --- a/scene/main/scene_main_loop.h +++ b/scene/main/scene_main_loop.h @@ -76,8 +76,9 @@ private: struct Group { Vector nodes; - uint64_t last_tree_version; - Group() { last_tree_version=0; }; + //uint64_t last_tree_version; + bool changed; + Group() { changed=false; }; }; Viewport *root; @@ -135,7 +136,7 @@ private: void _flush_ugc(); void _flush_transform_notifications(); - void _update_group_order(Group& g); + _FORCE_INLINE_ void _update_group_order(Group& g); void _update_listener(); Array _get_nodes_in_group(const StringName& p_group); @@ -162,7 +163,7 @@ friend class Node; void node_removed(Node *p_node); - void add_to_group(const StringName& p_group, Node *p_node); + Group* add_to_group(const StringName& p_group, Node *p_node); void remove_from_group(const StringName& p_group, Node *p_node); void _notify_group_pause(const StringName& p_group,int p_notification); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 01a6e3514c8..cc5a44a650d 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -2414,6 +2414,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { _menu_option_confirm(RUN_STOP,true); + exiting=true; get_tree()->quit(); } break; @@ -2747,6 +2748,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } _menu_option_confirm(RUN_STOP,true); + exiting=true; get_tree()->quit(); String exec = OS::get_singleton()->get_executable_path(); @@ -5244,6 +5246,7 @@ EditorNode::EditorNode() { singleton=this; + exiting=false; last_checked_version=0; changing_scene=false; _initializing_addons=false; diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 7d9b11ed834..65a5687dce0 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -227,6 +227,7 @@ private: Tabs *scene_tabs; int tab_closing; + bool exiting; int old_split_ofs; VSplitContainer *top_split; @@ -712,6 +713,8 @@ public: void update_keying(); + bool is_exiting() const { return exiting; } + ToolButton *get_pause_button() { return pause_button; } diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 3258bc6d748..2f0ba2da990 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -247,7 +247,8 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty hint=p_hint; hint_text=p_hint_text; type_button->hide(); - color_picker->hide(); + if (color_picker) + color_picker->hide(); texture_preview->hide(); inheritors_array.clear(); text_edit->hide(); @@ -596,6 +597,16 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty } break; case Variant::COLOR: { + if (!color_picker) { + //late init for performance + color_picker = memnew( ColorPicker ); + add_child(color_picker); + color_picker->hide(); + color_picker->set_area_as_parent_rect(); + for(int i=0;i<4;i++) + color_picker->set_margin((Margin)i,5); + color_picker->connect("color_changed",this,"_color_changed"); + } color_picker->show(); color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA); @@ -1757,13 +1768,9 @@ CustomPropertyEditor::CustomPropertyEditor() { action_buttons[i]->connect("pressed", this,"_action_pressed",binds); } - color_picker = memnew( ColorPicker ); - add_child(color_picker); - color_picker->hide(); - color_picker->set_area_as_parent_rect(); - for(int i=0;i<4;i++) - color_picker->set_margin((Margin)i,5); - color_picker->connect("color_changed",this,"_color_changed"); + color_picker=NULL; + + set_as_toplevel(true); file = memnew ( EditorFileDialog ); diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index bc12ff23e55..f8ce121690c 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -461,6 +461,9 @@ void SceneTreeEditor::_node_script_changed(Node *p_node) { void SceneTreeEditor::_node_removed(Node *p_node) { + if (EditorNode::get_singleton()->is_exiting()) + return; //speed up exit + if (p_node->is_connected("script_changed",this,"_node_script_changed")) p_node->disconnect("script_changed",this,"_node_script_changed"); @@ -534,6 +537,8 @@ void SceneTreeEditor::_test_update_tree() { void SceneTreeEditor::_tree_changed() { + if (EditorNode::get_singleton()->is_exiting()) + return; //speed up exit if (pending_test_update) return; if (tree_dirty)