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

List:       amarok
Subject:    [PATCH] proposed fix for the "amarok freezes when the install mp3
From:       Sascha Sommer <ssommer () suse ! de>
Date:       2007-08-29 12:34:04
Message-ID: 200708291434.04486.ssommer () suse ! de
[Download RAW message or body]

Hi,

the attached patch fixes

https://bugs.kde.org/show_bug.cgi?id=147126
https://bugzilla.novell.com/show_bug.cgi?id=304202

"After loading an mp3 in amarok, I get a popup that asks if I want to install
mp3 support.  This is an excellent idea and feature -- but it doesn't work. 
Amarok freezes right off, and is un-usable. I then have to kill it."

The problem seems to be that EngineController::canDecode runs in a seperate 
thread than the gui thread. Opening up a Kmessagebox there will prevent 
amarok from handling all gui events and everything will freeze. I therefore 
put the dialog into an extra function that will later get called from the 
statusBar.

The canDecode then only has to send an event to the statusBar in order to 
display the dialog.

Better solutions?


Regards

Sascha

["amarok-mp3-dialog.patch" (text/x-diff)]

--- amarok-1.4.7.org/amarok/src/enginecontroller.h	2007-08-07 19:48:28.000000000 \
                +0200
+++ amarok-1.4.7/amarok/src/enginecontroller.h	2007-08-29 14:07:27.000000000 +0200
@@ -45,6 +45,7 @@
     static EngineController* instance();
     static EngineBase*       engine() { return instance()->m_engine; }
     static bool              canDecode( const KURL& );
+    void unplayableNotification();
     static ExtensionCache&   extensionCache() { return s_extensionCache; }
     static QString           engineProperty( const QString& key ) { return \
                engine()->pluginProperty( key ); }
     static bool              hasEngineProperty( const QString& key ) { return \
                engine()->hasPluginProperty( key ); }
--- amarok-1.4.7.org/amarok/src/enginecontroller.cpp	2007-08-07 19:48:28.000000000 \
                +0200
+++ amarok-1.4.7/amarok/src/enginecontroller.cpp	2007-08-29 14:07:16.000000000 +0200
@@ -244,13 +244,10 @@
     if( engine() != EngineController::instance()->m_voidEngine )
     {
         //we special case this as otherwise users hate us
-        if ( !valid && ext.lower() == "mp3" && \
                !installDistroCodec(AmarokConfig::soundSystem()) )
-            Amarok::StatusBar::instance()->longMessageThreadSafe(
-                    i18n( "<p>The %1 claims it <b>cannot</b> play MP3 files."
-                        "<p>You may want to choose a different engine from the \
                <i>Configure Dialog</i>, or examine "
-                        "the installation of the multimedia-framework that the \
                current engine uses. "
-                        "<p>You may find useful information in the <i>FAQ</i> \
                section of the <i>Amarok HandBook</i>." )
-                    .arg( AmarokConfig::soundSystem() ), KDE::StatusBar::Error );
+        if ( !valid && ext.lower() == "mp3"){
+            QCustomEvent * e = new QCustomEvent( 2000 );
+            QApplication::postEvent( Amarok::StatusBar::instance(), e );
+	}
 
         // Cache this result for the next lookup
         if ( !ext.isEmpty() )
@@ -260,6 +257,17 @@
     return valid;
 }
 
+void EngineController::unplayableNotification() {
+
+    if( !installDistroCodec(AmarokConfig::soundSystem()))
+        Amarok::StatusBar::instance()->longMessageThreadSafe(
+                  i18n( "<p>The %1 claims it <b>cannot</b> play MP3 files."
+                        "<p>You may want to choose a different engine from the \
<i>Configure Dialog</i>, or examine " +                        "the installation of \
the multimedia-framework that the current engine uses. " +                        \
"<p>You may find useful information in the <i>FAQ</i> section of the <i>Amarok \
HandBook</i>." ) +                    .arg( AmarokConfig::soundSystem() ), \
KDE::StatusBar::Error ); +}
+
 bool EngineController::installDistroCodec( const QString& engine /*Filetype type*/)
 {
     KService::Ptr service = KTrader::self()->query( "Amarok/CodecInstall"
--- amarok-1.4.7.org/amarok/src/statusbar/statusBarBase.cpp	2007-08-07 \
                19:48:28.000000000 +0200
+++ amarok-1.4.7/amarok/src/statusbar/statusBarBase.cpp	2007-08-29 14:07:51.000000000 \
+0200 @@ -25,6 +25,7 @@
 #include "squeezedtextlabel.h"
 #include "statusBarBase.h"
 #include "threadmanager.h"
+#include "enginecontroller.h"
 
 #include <kio/job.h>
 #include <kiconloader.h>
@@ -343,9 +344,13 @@
 void
 StatusBar::customEvent( QCustomEvent *e )
 {
-    QString *s = static_cast<QString*>( e->data() );
-    longMessage( *s );
-    delete s;
+    if(e->type() == 1000 ){ 
+      QString *s = static_cast<QString*>( e->data() );
+      longMessage( *s );
+      delete s;
+    }else if(e->type() == 2000 ){
+      EngineController::instance()->unplayableNotification();
+    }
 }
 
 



_______________________________________________
Amarok mailing list
Amarok@kde.org
https://mail.kde.org/mailman/listinfo/amarok


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

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