mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
DropShadower: Fix bug when setOwner() is called with a component without a parent
Until now when a Component without a parent was passed to setOwner() the ParentVisibilityChangedListener would not install any hooks to any components, hence it would not be notified, when the owner was added to a parent.
This commit is contained in:
parent
751c4177a4
commit
ced221df4a
1 changed files with 7 additions and 8 deletions
|
|
@ -82,8 +82,7 @@ public:
|
|||
ParentVisibilityChangedListener (Component& r, ComponentListener& l)
|
||||
: root (&r), listener (&l)
|
||||
{
|
||||
if (auto* firstParent = root->getParentComponent())
|
||||
updateParentHierarchy (firstParent);
|
||||
updateParentHierarchy();
|
||||
|
||||
if ((SystemStats::getOperatingSystemType() & SystemStats::Windows) != 0)
|
||||
{
|
||||
|
|
@ -99,16 +98,16 @@ public:
|
|||
comp->removeComponentListener (this);
|
||||
}
|
||||
|
||||
void componentVisibilityChanged (Component&) override
|
||||
void componentVisibilityChanged (Component& component) override
|
||||
{
|
||||
listener->componentVisibilityChanged (*root);
|
||||
if (root != &component)
|
||||
listener->componentVisibilityChanged (*root);
|
||||
}
|
||||
|
||||
void componentParentHierarchyChanged (Component& component) override
|
||||
{
|
||||
if (root == &component)
|
||||
if (auto* firstParent = root->getParentComponent())
|
||||
updateParentHierarchy (firstParent);
|
||||
updateParentHierarchy();
|
||||
}
|
||||
|
||||
bool isWindowOnVirtualDesktop() const noexcept { return isOnVirtualDesktop; }
|
||||
|
|
@ -129,13 +128,13 @@ private:
|
|||
WeakReference<Component> ref;
|
||||
};
|
||||
|
||||
void updateParentHierarchy (Component* rootComponent)
|
||||
void updateParentHierarchy()
|
||||
{
|
||||
const auto lastSeenComponents = std::exchange (observedComponents, [&]
|
||||
{
|
||||
std::set<ComponentWithWeakReference> result;
|
||||
|
||||
for (auto node = rootComponent; node != nullptr; node = node->getParentComponent())
|
||||
for (auto node = root; node != nullptr; node = node->getParentComponent())
|
||||
result.emplace (*node);
|
||||
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue