proper way to switch playlists

Felix Berger bflat1 at gmx.net
Fri Apr 15 13:19:36 BST 2005


Hi,

we received a bug report for iList that noatun crashes when the user tries to 
switch to a different playlist. I reproduced this on my system and got the 
following backtrace:

[KCrash handler]
#5  0x006e0065 in ?? ()
#6  0x4007ca81 in Player::posTimeout () from /usr/lib/libnoatun.so.1
#7  0x4007da37 in Player::qt_invoke () from /usr/lib/libnoatun.so.1
#8  0x4135771c in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#9  0x41357544 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#10 0x4169881b in QTimer::timeout () from /usr/lib/libqt-mt.so.3
#11 0x41378f72 in QTimer::event () from /usr/lib/libqt-mt.so.3
#12 0x412fae1f in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#13 0x412fa41e in QApplication::notify () from /usr/lib/libqt-mt.so.3
#14 0x40e8ae43 in KApplication::notify () from /usr/lib/libkdecore.so.4
#15 0x412ea645 in QEventLoop::activateTimers () from /usr/lib/libqt-mt.so.3
#16 0x412a3cfb in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#17 0x4130d1d8 in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#18 0x4130d088 in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#19 0x412fb071 in QApplication::exec () from /usr/lib/libqt-mt.so.3
#20 0x40031346 in kdemain () from /usr/lib/libkdeinit_noatun.so
#21 0x0804885b in ?? ()
#22 0x00000001 in ?? ()
#23 0xbffff874 in ?? ()
#24 0xbffff848 in ?? ()
#25 0x420d5dc6 in __libc_start_main () from /lib/libc.so.6
#26 0x420d5dc6 in __libc_start_main () from /lib/libc.so.6
#27 0x08048791 in ?? ()

I then produced the following backtrace with  the lines

  currentItem = PlaylistItem();
  emit playCurrent();

in iList's destructor as is recommended in:

	/**
	 * on playlist unload, your playlist must
	 * have current()==0 and emit playCurrent
	 **/
        virtual ~Playlist();

[KCrash handler]
#5  0x4007c84f in Player::playCurrent () from /usr/lib/libnoatun.so.1
#6  0x4007da17 in Player::qt_invoke () from /usr/lib/libnoatun.so.1
#7  0x4135771c in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#8  0x41357544 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#9  0x4007af3b in Playlist::playCurrent () from /usr/lib/libnoatun.so.1
#10 0x42cff5e5 in ~IList (this=0x8182530) at ilist.cpp:93
#11 0x400894f0 in LibraryLoader::removeNow () from /usr/lib/libnoatun.so.1
#12 0x400885db in LibraryLoader::remove () from /usr/lib/libnoatun.so.1
#13 0x400889ef in LibraryLoader::remove () from /usr/lib/libnoatun.so.1
#14 0x4006f0b4 in Plugins::save () from /usr/lib/libnoatun.so.1
#15 0x4007b57b in NoatunPreferences::slotApply () from /usr/lib/libnoatun.so.1
#16 0x4007b467 in NoatunPreferences::slotOk () from /usr/lib/libnoatun.so.1
#17 0x40ca0a47 in KDialogBase::qt_invoke () from /usr/lib/libkdeui.so.4
#18 0x4007bb9d in NoatunPreferences::qt_invoke () from /usr/lib/libnoatun.so.1
#19 0x4135771c in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#20 0x41357544 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#21 0x4169d82e in QButton::clicked () from /usr/lib/libqt-mt.so.3
#22 0x413e9f94 in QButton::mouseReleaseEvent () from /usr/lib/libqt-mt.so.3
#23 0x4138db37 in QWidget::event () from /usr/lib/libqt-mt.so.3
#24 0x412fae1f in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#25 0x412fa514 in QApplication::notify () from /usr/lib/libqt-mt.so.3
#26 0x40e8ae43 in KApplication::notify () from /usr/lib/libkdecore.so.4
#27 0x4128f5b0 in QETWidget::translateMouseEvent () 
from /usr/lib/libqt-mt.so.3
#28 0x4128d23e in QApplication::x11ProcessEvent () from /usr/lib/libqt-mt.so.3
#29 0x412a4254 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#30 0x4130d1d8 in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#31 0x4130d088 in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#32 0x412fb071 in QApplication::exec () from /usr/lib/libqt-mt.so.3
#33 0x40031346 in kdemain () from /usr/lib/libkdeinit_noatun.so
#34 0x0804885b in ?? ()
#35 0x00000001 in ?? ()
#36 0xbffff874 in ?? ()
#37 0xbffff848 in ?? ()
#38 0x420d5dc6 in __libc_start_main () from /lib/libc.so.6
#39 0x420d5dc6 in __libc_start_main () from /lib/libc.so.6
#40 0x08048791 in ?? ()

We already removed any qApp->processEvents() code from the destructor which we 
used for updating our saving progress. That's why a flag given to the 
playlist would be useful to know if it's a shutdown or a playlist switch so 
that event processing can be enabled in the shutdown case.

Maybe an additional null pointer check fixes this:

void Player::playCurrent()
{
	if (!mEngine->initialized()) return;
	stop();
	mCurrent=0;
-       if (napp->playlist()->current())
+	if (napp->playlist() && napp->playlist()->current())
		play();
}

Otherwise stopping the player and restoring its playstate after the playlist 
switch might also be a good idea.

Felix

-- 
Try Debian GNU/Linux!
http://www.felix.beldesign.de/



More information about the kde-multimedia mailing list