Commit 5f913836 authored by Michael Pyne's avatar Michael Pyne

Two bugfixes:

1. Don't allow JuK to shutdown until Phonon has definitely returned to StoppedState to prevent some backends
from crashing on shutdown.

2. Delay system tray creation until after the collection list has been loaded from the cache.  If we're
trying to create the system tray before this process then half the time we end up freezing all of Plasma
until the cache finally loads, which is especially noticable on initial KDE startup.

I will give this a few days of testing in /trunk and will then probably backport both.

svn path=/trunk/KDE/kdemultimedia/juk/; revision=921339
parent 6621e1c9
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
copyright : (C) 2002 - 2004 by Scott Wheeler copyright : (C) 2002 - 2004 by Scott Wheeler
email : wheeler@kde.org email : wheeler@kde.org
copyright : (C) 2008 by Michael Pyne copyright : (C) 2008, 2009 by Michael Pyne
email : michael.pyne@kdemail.net email : michael.pyne@kdemail.net
***************************************************************************/ ***************************************************************************/
...@@ -91,8 +91,8 @@ JuK::JuK(QWidget *parent) : ...@@ -91,8 +91,8 @@ JuK::JuK(QWidget *parent) :
else else
setupGUI(ToolBar | Save | Create); setupGUI(ToolBar | Save | Create);
connect(m_splitter, SIGNAL(guiReady()), SLOT(slotSetupSystemTray()));
readConfig(); readConfig();
setupSystemTray();
setupGlobalAccels(); setupGlobalAccels();
// slotCheckCache loads the cached entries first to populate the collection list // slotCheckCache loads the cached entries first to populate the collection list
...@@ -279,7 +279,7 @@ void JuK::setupActions() ...@@ -279,7 +279,7 @@ void JuK::setupActions()
action->setShortcutContext(Qt::WidgetWithChildrenShortcut); action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
} }
void JuK::setupSystemTray() void JuK::slotSetupSystemTray()
{ {
if(m_toggleSystemTrayAction && m_toggleSystemTrayAction->isChecked()) { if(m_toggleSystemTrayAction && m_toggleSystemTrayAction->isChecked()) {
m_systemTray = new SystemTray(this); m_systemTray = new SystemTray(this);
...@@ -465,13 +465,10 @@ void JuK::slotAboutToQuit() ...@@ -465,13 +465,10 @@ void JuK::slotAboutToQuit()
{ {
m_shuttingDown = true; m_shuttingDown = true;
action("stop")->trigger();
delete m_systemTray; delete m_systemTray;
m_systemTray = 0; m_systemTray = 0;
CoverManager::shutdown(); CoverManager::shutdown();
Cache::instance()->save();
saveConfig();
delete m_splitter; delete m_splitter;
m_splitter = 0; m_splitter = 0;
...@@ -481,6 +478,22 @@ void JuK::slotQuit() ...@@ -481,6 +478,22 @@ void JuK::slotQuit()
{ {
m_shuttingDown = true; m_shuttingDown = true;
// Some phonon backends will crash on shutdown unless we're deep in the middle of the StoppedState.
// So have the PlayerManager tell us when we're stopped and we'll continue.
if(m_player->playing()) {
connect(m_player, SIGNAL(signalStop()), SLOT(slotPlaybackStopped()));
m_player->stop();
}
else
QTimer::singleShot(0, this, SLOT(slotPlaybackStopped()));
// Get these started since they don't involve deleting any running objects.
Cache::instance()->save();
saveConfig();
}
void JuK::slotPlaybackStopped()
{
kapp->quit(); kapp->quit();
} }
...@@ -491,7 +504,7 @@ void JuK::slotQuit() ...@@ -491,7 +504,7 @@ void JuK::slotQuit()
void JuK::slotToggleSystemTray(bool enabled) void JuK::slotToggleSystemTray(bool enabled)
{ {
if(enabled && !m_systemTray) if(enabled && !m_systemTray)
setupSystemTray(); slotSetupSystemTray();
else if(!enabled && m_systemTray) { else if(!enabled && m_systemTray) {
delete m_systemTray; delete m_systemTray;
m_systemTray = 0; m_systemTray = 0;
......
...@@ -45,7 +45,6 @@ public: ...@@ -45,7 +45,6 @@ public:
private: private:
void setupLayout(); void setupLayout();
void setupActions(); void setupActions();
void setupSystemTray();
void setupGlobalAccels(); void setupGlobalAccels();
void keyPressEvent(QKeyEvent *); void keyPressEvent(QKeyEvent *);
...@@ -62,9 +61,11 @@ private: ...@@ -62,9 +61,11 @@ private:
virtual bool queryClose(); virtual bool queryClose();
private slots: private slots:
void slotSetupSystemTray();
void slotShowHide(); void slotShowHide();
void slotAboutToQuit(); void slotAboutToQuit();
void slotQuit(); void slotQuit();
void slotPlaybackStopped();
void slotToggleSystemTray(bool enabled); void slotToggleSystemTray(bool enabled);
void slotEditKeys(); void slotEditKeys();
void slotConfigureTagGuesser(); void slotConfigureTagGuesser();
......
...@@ -288,8 +288,6 @@ void PlayerManager::stop() ...@@ -288,8 +288,6 @@ void PlayerManager::stop()
stopCrossfade(); stopCrossfade();
m_media[0]->stop(); m_media[0]->stop();
m_media[1]->stop(); m_media[1]->stop();
emit signalStop();
} }
void PlayerManager::setVolume(float volume) void PlayerManager::setVolume(float volume)
...@@ -485,6 +483,7 @@ void PlayerManager::slotStateChanged(Phonon::State newstate, Phonon::State oldst ...@@ -485,6 +483,7 @@ void PlayerManager::slotStateChanged(Phonon::State newstate, Phonon::State oldst
// song when one is playing now), since it didn't occur in the error handler. Just // song when one is playing now), since it didn't occur in the error handler. Just
// in case we really did abruptly stop, handle that case in a couple of seconds. // in case we really did abruptly stop, handle that case in a couple of seconds.
QTimer::singleShot(2000, this, SLOT(slotUpdateGuiIfStopped())); QTimer::singleShot(2000, this, SLOT(slotUpdateGuiIfStopped()));
emit signalStop();
} }
else if(newstate == Phonon::PlayingState) { else if(newstate == Phonon::PlayingState) {
action("pause")->setEnabled(true); action("pause")->setEnabled(true);
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
begin : Fri Sep 13 2002 begin : Fri Sep 13 2002
copyright : (C) 2002 - 2004 by Scott Wheeler copyright : (C) 2002 - 2004 by Scott Wheeler
email : wheeler@kde.org email : wheeler@kde.org
copyright : (C) 2009 by Michael Pyne
email : michael.pyne@kdemail.net
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
...@@ -195,6 +198,9 @@ void PlaylistSplitter::setupLayout() ...@@ -195,6 +198,9 @@ void PlaylistSplitter::setupLayout()
m_editor, SLOT(slotPlaylistDestroyed(Playlist *))); m_editor, SLOT(slotPlaylistDestroyed(Playlist *)));
connect(m_playlistBox, SIGNAL(startupComplete()), SLOT(slotEnable())); connect(m_playlistBox, SIGNAL(startupComplete()), SLOT(slotEnable()));
// Let interested parties know we're ready
connect(m_playlistBox, SIGNAL(startupComplete()), SIGNAL(guiReady()));
insertWidget(0, m_playlistBox); insertWidget(0, m_playlistBox);
m_nowPlaying = new NowPlaying(top, m_playlistBox); m_nowPlaying = new NowPlaying(top, m_playlistBox);
......
...@@ -48,6 +48,14 @@ public: ...@@ -48,6 +48,14 @@ public:
virtual bool eventFilter(QObject *watched, QEvent *event); virtual bool eventFilter(QObject *watched, QEvent *event);
signals:
/**
* Emitted when GUI is created and the cache is loaded. Is kind of a hack
* until we move the time-intensive parts to a separate thread but then
* again at least this works.
*/
void guiReady();
public slots: public slots:
virtual void setFocus(); virtual void setFocus();
virtual void slotFocusCurrentPlaylist(); virtual void slotFocusCurrentPlaylist();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment