[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Patch KParts::StatusBarExtension...
From:       Dawit A <adawit () kde ! org>
Date:       2010-03-01 4:02:05
Message-ID: 201002282302.05405.adawit () kde ! org
[Download RAW message or body]

Hi,

The attached patch fixes crashes that occur due to unexpected deletion of the 
m_widget variable in the internal class KParts::StatusBarItem. This can happen 
when a KUrlLabel  is deleted by the application or plugin that added it to the 
status bar for example. 

The patch simply changes the m_widget variable to a QPointer to guard against 
external deletions and checks the validity of the variable before use.

Regards,
Dawit A.

["kparts_statusbarextension.patch" (text/x-patch)]

Index: statusbarextension.cpp
=============================
--- statusbarextension.cpp	(revision 1093976)
+++ statusbarextension.cpp	(working copy)
@@ -47,7 +47,7 @@
 
     void ensureItemShown( KStatusBar * sb )
     {
-      if ( !m_visible )
+      if ( m_widget && !m_visible )
       {
         if ( m_permanent )
             sb->addPermanentWidget( m_widget, m_stretch );
@@ -59,7 +59,7 @@
     }
     void ensureItemHidden( KStatusBar * sb )
     {
-      if ( m_visible )
+      if ( m_widget && m_visible )
       {
         sb->removeWidget( m_widget );
         m_visible = false;
@@ -67,7 +67,7 @@
       }
     }
   private:
-    QWidget * m_widget;
+    QPointer<QWidget> m_widget;
     int m_stretch;
     bool m_permanent;
     bool m_visible;  // true when the item has been added to the statusbar


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic