widget: don't crash when deallocating in wrong order
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 19 Dec 2005 00:13:44 +0000 (00:13 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 19 Dec 2005 00:13:44 +0000 (00:13 +0000)
lib/gui/ewidget.cpp
lib/gui/ewidgetdesktop.cpp

index 6f7fa91..3bc6e66 100644 (file)
@@ -140,6 +140,8 @@ void eWidget::hide()
        while (root && !root->m_desktop)
        {
                root = root->m_parent;
+               if (!root)
+                       return;
                abspos += root->position();
        }
        assert(root->m_desktop);
index c89cd27..04bc85d 100644 (file)
@@ -325,6 +325,12 @@ eWidgetDesktop::eWidgetDesktop(eSize size): m_mainloop(0), m_timer(0)
 
 eWidgetDesktop::~eWidgetDesktop()
 {
+               /* tell registered root windows that they no longer have a desktop. */
+       for (ePtrList<eWidget>::iterator i(m_root.begin()); i != m_root.end(); )
+       {
+               i->m_desktop = 0;
+               i = m_root.erase(i);
+       }
                /* destroy all buffers */
        setCompositionMode(-1);
 }