davidedmundson accepted this revision.
davidedmundson added a comment.
This revision is now accepted and ready to land.


  Heh, finally found the bug.
  
  I was a bit wrong.
  QObject::destroyed() is emitted before we delete the children.
  
  But that still doesn't explain everything, the containment won't get deleted 
till after the child applet is deleted; so why would containment() be null?
  We know it's not deleted yet, so it's not really "gone" like your comment 
says,
  
  The issue is that containment() is a qobject_cast recursive search of 
parents. (for some reason)
  
  qobject_cast calls metaobject() which is virtual. Calling a virtual method 
during an objects destructor can result in unexpected behaviour. 
  Our parent is still valid, but we've called Containment::~Containment, 
Applet::~Applet  and we're currently in QObject::~QObject, so when we call a 
method on a base class it doesn't get dynamically dispatched as it should.
  
  So when we call parent()->metaObject() we now get the metaobject for QObject 
not the metaobject of Containment.
  
  This means the qobject_cast fails, and that's why Applet::containment() is 
null even though the containment is still there.

REPOSITORY
  R120 Plasma Workspace

REVISION DETAIL
  https://phabricator.kde.org/D5321

To: broulik, #plasma, davidedmundson
Cc: davidedmundson, plasma-devel, progwolff, lesliezhai, ali-mohamed, 
jensreuterberg, abetts, sebas, apol

Reply via email to