fix ui elements overriding
This commit is contained in:
parent
5ae34c2dc2
commit
d7f3bf9c7c
@ -45,7 +45,7 @@ std::shared_ptr<gui::UINode> UiDocument::get(const std::string& id) const {
|
|||||||
if (found == map.end()) {
|
if (found == map.end()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return found->second;
|
return found->second.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
const uidocscript& UiDocument::getScript() const {
|
const uidocscript& UiDocument::getScript() const {
|
||||||
|
|||||||
@ -19,7 +19,7 @@ struct uidocscript {
|
|||||||
bool onclose : 1;
|
bool onclose : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
using UINodesMap = std::unordered_map<std::string, std::shared_ptr<gui::UINode>>;
|
using UINodesMap = std::unordered_map<std::string, std::weak_ptr<gui::UINode>>;
|
||||||
|
|
||||||
class UiDocument {
|
class UiDocument {
|
||||||
std::string id;
|
std::string id;
|
||||||
|
|||||||
@ -385,11 +385,14 @@ bool UINode::isSubnodeOf(const UINode* node) {
|
|||||||
|
|
||||||
void UINode::getIndices(
|
void UINode::getIndices(
|
||||||
const std::shared_ptr<UINode>& node,
|
const std::shared_ptr<UINode>& node,
|
||||||
std::unordered_map<std::string, std::shared_ptr<UINode>>& map
|
std::unordered_map<std::string, std::weak_ptr<UINode>>& map
|
||||||
) {
|
) {
|
||||||
const std::string& id = node->getId();
|
const std::string& id = node->getId();
|
||||||
if (!id.empty()) {
|
if (!id.empty()) {
|
||||||
map[id] = node;
|
const auto& found = map.find(id);
|
||||||
|
if (found == map.end() || found->second.expired()) {
|
||||||
|
map[id] = node;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto container = std::dynamic_pointer_cast<gui::Container>(node);
|
auto container = std::dynamic_pointer_cast<gui::Container>(node);
|
||||||
if (container) {
|
if (container) {
|
||||||
|
|||||||
@ -289,7 +289,7 @@ namespace gui {
|
|||||||
/// @brief collect all nodes having id
|
/// @brief collect all nodes having id
|
||||||
static void getIndices(
|
static void getIndices(
|
||||||
const std::shared_ptr<UINode>& node,
|
const std::shared_ptr<UINode>& node,
|
||||||
std::unordered_map<std::string, std::shared_ptr<UINode>>& map
|
std::unordered_map<std::string, std::weak_ptr<UINode>>& map
|
||||||
);
|
);
|
||||||
|
|
||||||
static std::shared_ptr<UINode> find(
|
static std::shared_ptr<UINode> find(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user