Blob Blame History Raw
From 1aa560ce6516556703e2ece183354f606b602897 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Wed, 29 Oct 2014 17:12:40 +0000
Subject: [PATCH] Resolves: rhbz#1146169 a11y frames label dies before frame

Change-Id: I2bc45dcb92b8e68bf4ae4df72c0fbd4e3b535604
---
 include/vcl/layout.hxx       |  1 +
 vcl/source/window/layout.cxx | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index d758d63..8bad8e7 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -458,6 +458,7 @@ private:
 private:
     friend class VclBuilder;
     void designate_label(Window *pWindow);
+    DECL_LINK(WindowEventListener, VclSimpleEvent*);
 public:
     VclFrame(Window *pParent)
         : VclBin(pParent)
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 06f387b..6db0f15 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1338,10 +1338,21 @@ void VclFrame::setAllocation(const Size &rAllocation)
         setLayoutAllocation(*pChild, aChildPos, aAllocation);
 }
 
+IMPL_LINK(VclFrame, WindowEventListener, VclSimpleEvent*, pEvent)
+{
+    if (pEvent && pEvent->GetId() == VCLEVENT_OBJECT_DYING)
+        designate_label(NULL);
+    return 0;
+}
+
 void VclFrame::designate_label(Window *pWindow)
 {
-    assert(pWindow->GetParent() == this);
+    assert(!pWindow || pWindow->GetParent() == this);
+    if (m_pLabel)
+        m_pLabel->RemoveEventListener(LINK(this, VclFrame, WindowEventListener));
     m_pLabel = pWindow;
+    if (m_pLabel)
+        m_pLabel->AddEventListener(LINK(this, VclFrame, WindowEventListener));
 }
 
 const Window *VclFrame::get_label_widget() const
-- 
1.9.3