Bug 142071

Summary: Screensaver crashes when trying to switch media
Product: kscreensaver Reporter: Casper Guldberg <casper.guldberg>
Component: kpartsaverAssignee: kscreensaver bugs tracking <kscreensaver-bugs-null>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:

Description Casper Guldberg 2007-02-22 18:53:55 UTC
Version:            (using KDE KDE 3.5.6)
Installed from:    Ubuntu Packages
OS:                Linux

Plays the first media on the list very nicely. Then when trying to switch it crashes.

see https://launchpad.net/mandriva/+bug/35605 for details
Comment 1 Martin Koller 2007-02-25 13:26:23 UTC
SVN commit 637099 by mkoller:

BUG: 142071

Fix crash by not deletsinge KLibFactory when loading next part. We do not own it.



 M  +5 -13     kpartsaver.cpp  
 M  +0 -2      kpartsaver.h  


--- branches/KDE/3.5/kdeartwork/kscreensaver/kpartsaver/kpartsaver.cpp #637098:637099
@@ -87,7 +87,7 @@
 
 
 KPartSaver::KPartSaver( WId id )
-    : KScreenSaver( id ), m_timer(), m_part(0), m_current(-1), m_factory(0), m_back(0)
+    : KScreenSaver( id ), m_timer(), m_part(0), m_current(-1), m_back(0)
 {
     // install signal handlers to make sure that nspluginviewer is shutdown correctly
     // move this into the nspluginviewer kpart code
@@ -160,16 +160,12 @@
         delete m_part;
         m_part = 0;
     }
-
-    delete m_factory;
-    m_factory = 0;
 }
 
 
 bool KPartSaver::openURL( KURL url )
 {
-    if( m_part )
-        closeURL();
+    closeURL();
 
     // find mime type
     QString mime = KMimeType::findByURL( url )->name();
@@ -184,18 +180,16 @@
 
     // load kpart library
     QString lib = offers.first()->library();
-    m_factory = KLibLoader::self()->factory( lib.latin1() );
-    if( !m_factory ) {
+    KLibFactory *factory = KLibLoader::self()->factory( lib.latin1() );
+    if( !factory ) {
         kdDebug() << "Library " << lib << " not found." << endl;
-        closeURL();
         return false;
     }
 
     // create kpart
-    m_part = (KParts::ReadOnlyPart *)m_factory->create( this, "kpart", "KParts::ReadOnlyPart" );
+    m_part = (KParts::ReadOnlyPart *)factory->create( this, "kpart", "KParts::ReadOnlyPart" );
     if( !m_part ) {
         kdDebug() << "Part for " << url.url() << " can't be constructed" << endl;
-        closeURL();
         return false;
     } else
         embed( m_part->widget() );
@@ -210,8 +204,6 @@
     // load url
     if( !m_part->openURL( url ) ) {
         kdDebug() << "Can't load " << url.url() << endl;
-        delete m_part;
-        m_part = 0;
         closeURL();
         return false;
     }
--- branches/KDE/3.5/kdeartwork/kscreensaver/kpartsaver/kpartsaver.h #637098:637099
@@ -34,7 +34,6 @@
 #include <klocale.h>
 #include <kapplication.h>
 #include <kdebug.h>
-#include <klibloader.h>
 #include <kconfig.h>
 #include <kfiledialog.h>
 #include <kurl.h>
@@ -96,7 +95,6 @@
     bool m_random;
     int m_delay;
     QStringList m_files;
-    KLibFactory *m_factory;
     QLabel *m_back;
 };