[amarok] Wikipedia applet crashes (kde#279813)

Rex Dieter rdieter at fedoraproject.org
Mon Sep 19 15:32:39 UTC 2011


commit 1122c6123d4e711b2d39a3c53d446d759043aa37
Author: Rex Dieter <rdieter at fedoraproject.org>
Date:   Mon Sep 19 10:32:24 2011 -0500

    Wikipedia applet crashes (kde#279813)

 amarok-2.5-wikipedia_load.patch |  110 +++++++++++++++++++++++++++++++++++++++
 amarok.spec                     |    8 +++-
 2 files changed, 117 insertions(+), 1 deletions(-)
---
diff --git a/amarok-2.5-wikipedia_load.patch b/amarok-2.5-wikipedia_load.patch
new file mode 100644
index 0000000..68e26c9
--- /dev/null
+++ b/amarok-2.5-wikipedia_load.patch
@@ -0,0 +1,110 @@
+commit 027340cd9a8e01762d0ec0aafb46f4b05a7d29e8
+Author: Kevin Funk <krf at electrostorm.net>
+Date:   Sun Sep 18 23:37:11 2011 +0200
+
+    Fix crash in WikipediaApplet.
+    
+    The crash happened because of the loadProgress() signal triggering the
+    _pageLoadProgress() slot in the Wikipedia applet *after* the
+    _pageLoadFinished() has been triggered already.
+    That caused a null-pointer dereference.
+    
+    The actual problem is that we are not disconnecting from the webView
+    loadProgress() signal after some page loading has been finished.
+    
+    Also remove some not-so-pretty static_assert statements and use a more
+    type-safe approach to keep track of the progress bar proxy widget.
+    Use some soft asserts to avoid the worst-case when the proxy widget may
+    have been deleted somehow.
+    
+    BUG: 279813
+    FIXED-IN: 2.5
+
+diff --git a/src/context/applets/wikipedia/WikipediaApplet.cpp b/src/context/applets/wikipedia/WikipediaApplet.cpp
+index 1f8cd07..41412bf 100644
+--- a/src/context/applets/wikipedia/WikipediaApplet.cpp
++++ b/src/context/applets/wikipedia/WikipediaApplet.cpp
+@@ -464,10 +464,19 @@ void
+ WikipediaAppletPrivate::_pageLoadStarted()
+ {
+     Q_Q( WikipediaApplet );
+-    QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget;
+-    proxy->setWidget( new QProgressBar );
++
++    // create a proxy widget for displaying the webview load status in form of a progress bar
++
++    // if the proxyWidget still exists, re-use the existing object
++    if ( proxyWidget )
++        return;
++
++    proxyWidget = new QGraphicsProxyWidget;
++    proxyWidget->setWidget( new QProgressBar );
++
++    // add proxy widget to layout
+     QGraphicsLinearLayout *lo = static_cast<QGraphicsLinearLayout*>( q->layout() );
+-    lo->addItem( proxy );
++    lo->addItem( proxyWidget );
+     lo->activate();
+     QObject::connect( webView, SIGNAL(loadProgress(int)), q, SLOT(_pageLoadProgress(int)) );
+ }
+@@ -475,11 +484,13 @@ WikipediaAppletPrivate::_pageLoadStarted()
+ void
+ WikipediaAppletPrivate::_pageLoadProgress( int progress )
+ {
++    DEBUG_BLOCK
+     Q_Q( WikipediaApplet );
+-    QGraphicsLinearLayout *lo = static_cast<QGraphicsLinearLayout*>( q->layout() );
+-    QGraphicsProxyWidget *proxy = static_cast<QGraphicsProxyWidget*>( lo->itemAt( lo->count() - 1 ) );
+-    QString kbytes = QString::number( webView->page()->totalBytes() / 1024 );
+-    QProgressBar *pbar = static_cast<QProgressBar*>( proxy->widget() );
++    DEBUG_ASSERT(proxyWidget, return)
++
++    const QString kbytes = QString::number( webView->page()->totalBytes() / 1024 );
++
++    QProgressBar *pbar = qobject_cast<QProgressBar*>( proxyWidget->widget() );
+     pbar->setFormat( QString( "%1kB : %p%" ).arg( kbytes ) );
+     pbar->setValue( progress );
+ }
+@@ -487,13 +498,19 @@ WikipediaAppletPrivate::_pageLoadProgress( int progress )
+ void
+ WikipediaAppletPrivate::_pageLoadFinished( bool ok )
+ {
++    DEBUG_BLOCK
+     Q_UNUSED( ok )
+     Q_Q( WikipediaApplet );
++
++    // remove proxy widget from layout again, delete it
+     QGraphicsLinearLayout *lo = static_cast<QGraphicsLinearLayout*>( q->layout() );
+-    QGraphicsProxyWidget *proxy = static_cast<QGraphicsProxyWidget*>( lo->itemAt( lo->count() - 1 ) );
+-    lo->removeItem( proxy );
++    lo->removeItem( proxyWidget );
+     lo->activate();
+-    proxy->deleteLater();
++
++    // disconnect (so that we don't get any further progress signalling) and delete widget
++    QObject::disconnect( webView, SIGNAL(loadProgress(int)), q, SLOT(_pageLoadProgress(int)) );
++    proxyWidget->deleteLater();
++    proxyWidget = 0;
+ }
+ 
+ void
+diff --git a/src/context/applets/wikipedia/WikipediaApplet_p.h b/src/context/applets/wikipedia/WikipediaApplet_p.h
+index d435b89..98bd007 100644
+--- a/src/context/applets/wikipedia/WikipediaApplet_p.h
++++ b/src/context/applets/wikipedia/WikipediaApplet_p.h
+@@ -65,6 +65,7 @@ public:
+         , settingsIcon( 0 )
+         , trackIcon( 0 )
+         , webView( 0 )
++        , proxyWidget( 0 )
+         , aspectRatio( 0 )
+         , isForwardHistory( false )
+         , isBackwardHistory( false )
+@@ -128,6 +129,7 @@ public:
+     Plasma::IconWidget *settingsIcon;
+     Plasma::IconWidget *trackIcon;
+     WikipediaWebView *webView;
++    QGraphicsProxyWidget *proxyWidget;
+     QStack<QUrl> historyBack;
+     QStack<QUrl> historyForward;
+     QUrl currentUrl;
diff --git a/amarok.spec b/amarok.spec
index b7fddce..199f245 100644
--- a/amarok.spec
+++ b/amarok.spec
@@ -2,7 +2,7 @@
 Name:    amarok
 Summary: Media player
 Version: 2.4.3
-Release: 2%{?dist}
+Release: 3%{?dist}
 
 Group: 	 Applications/Multimedia
 # KDE e.V. may determine that future GPL versions are accepted
@@ -14,6 +14,8 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 #Patch50: amarok-2.2.1.90-qtscript_not_required.patch
 
 ## upstream patches
+# https://projects.kde.org/projects/extragear/multimedia/amarok/repository/revisions/027340cd9a8e01762d0ec0aafb46f4b05a7d29e8 
+Patch100: amarok-2.5-wikipedia_load.patch
 
 BuildRequires: curl-devel
 BuildRequires: desktop-file-utils
@@ -80,6 +82,7 @@ Obsoletes: amarok-utilities < 2.0.96
 %setup -q 
 
 #patch50 -p1 -b .qtscript_not_required
+%patch100 -p1 -b .wikipedia_load
 
 
 %build
@@ -177,6 +180,9 @@ fi
 
 
 %changelog
+* Mon Sep 19 2011 Rex Dieter <rdieter at fedoraproject.org> 2.4.3-3
+- Wikipedia applet crashes (kde#279813)
+
 * Fri Sep 16 2011 Rex Dieter <rdieter at fedoraproject.org> 2.4.3-2
 - re-enable libgpod support inadvertantly lost in 2.4.1.90-1
 


More information about the scm-commits mailing list