From kde-commits Sun Jan 22 17:20:59 2006 From: Mark Kretschmann Date: Sun, 22 Jan 2006 17:20:59 +0000 To: kde-commits Subject: extragear/multimedia/amarok/src Message-Id: <1137950459.895437.26538.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=113795048313499 SVN commit 501345 by markey: * Remove the option "Restart running scripts on next app start". It was fairly pointless the way it worked. Scripts are now always being restarted. Perhaps it would make sense to introduce a per script "autorun" setting, I'm not sure. Gimmick or useful? * Remove some code duplication wrt script termination. M +24 -30 scriptmanager.cpp M +3 -0 scriptmanager.h M +2 -32 scriptmanagerbase.ui --- trunk/extragear/multimedia/amarok/src/scriptmanager.cpp #501344:501345 @@ -180,9 +180,7 @@ ScriptMap::Iterator end( m_scripts.end() ); for( it = m_scripts.begin(); it != end; ++it ) { if( it.data().process ) { - it.data().process->kill(); // Sends SIGTERM - it.data().process->detach(); - delete it.data().process; + terminateProcess( &it.data().process ); runningScripts << it.key(); } } @@ -190,7 +188,6 @@ // Save config KConfig* const config = amaroK::config( "ScriptManager" ); config->writeEntry( "Running Scripts", runningScripts ); - config->writeEntry( "Auto Run", m_gui->checkBox_autoRun->isChecked() ); s_instance = 0; } @@ -280,20 +277,14 @@ // Handle auto-run: KConfig* const config = amaroK::config( "ScriptManager" ); - const bool autoRun = config->readBoolEntry( "Auto Run", false ); - m_gui->checkBox_autoRun->setChecked( autoRun ); + const QStringList runningScripts = config->readListEntry( "Running Scripts" ); - if( autoRun ) { - const QStringList runningScripts = config->readListEntry( "Running Scripts" ); - - QStringList::ConstIterator it; - QStringList::ConstIterator end( runningScripts.end() ); - for( it = runningScripts.begin(); it != end; ++it ) { - if( m_scripts.contains( *it ) ) { - debug() << "Auto-running script: " << *it << endl; - m_gui->listView->setCurrentItem( m_scripts[*it].li ); - slotRunScript(); - } + end = runningScripts.end(); + for( it = runningScripts.begin(); it != end; ++it ) { + if( m_scripts.contains( *it ) ) { + debug() << "Auto-running script: " << *it << endl; + m_gui->listView->setCurrentItem( m_scripts[*it].li ); + slotRunScript(); } } @@ -456,16 +447,11 @@ if( it.data().url.directory() == directory ) keys << it.key(); - // Kill script processes, remove entries from script list + // Terminate script processes, remove entries from script list QStringList::Iterator itKeys; for( itKeys = keys.begin(); itKeys != keys.end(); ++itKeys ) { delete m_scripts[*itKeys].li; - if( m_scripts[*itKeys].process ) { - // Terminate script process (with SIGTERM) - m_scripts[*itKeys].process->kill(); - m_scripts[*itKeys].process->detach(); - delete m_scripts[*itKeys].process; - } + terminateProcess( &m_scripts[*itKeys].process ); m_scripts.erase( *itKeys ); } } @@ -519,12 +505,7 @@ if( m_scripts.find( name ) == m_scripts.end() ) return; - // Terminate script process (with SIGTERM) - m_scripts[name].process->kill(); - m_scripts[name].process->detach(); - - delete m_scripts[name].process; - m_scripts[name].process = 0; + terminateProcess( &m_scripts[name].process ); m_scripts[name].log = QString::null; slotCurrentChanged( m_gui->listView->currentItem() ); @@ -681,6 +662,19 @@ //////////////////////////////////////////////////////////////////////////////// void +ScriptManager::terminateProcess( KProcIO** proc ) +{ + if( *proc ) { + (*proc)->kill(); // Sends SIGTERM + (*proc)->detach(); + + delete *proc; + *proc = 0; + } +} + + +void ScriptManager::notifyScripts( const QString& message ) { DEBUG_BLOCK --- trunk/extragear/multimedia/amarok/src/scriptmanager.h #501344:501345 @@ -117,6 +117,9 @@ void scriptFinished( KProcess* process ); private: + /** Terminates a process with SIGTERM and deletes the KProcIO object */ + void terminateProcess( KProcIO** proc ); + /** Sends a string message to all running scripts */ void notifyScripts( const QString& message ); --- trunk/extragear/multimedia/amarok/src/scriptmanagerbase.ui #501344:501345 @@ -8,8 +8,8 @@ 0 0 - 366 - 292 + 367 + 237 @@ -19,20 +19,6 @@ unnamed - - - line2 - - - HLine - - - Sunken - - - Horizontal - - @@ -139,27 +125,11 @@ &Uninstall - - - checkBox_autoRun - - - R&estart running scripts on application startup - - - If enabled, amaroK will automatically restart scripts that were running when you exited the application. - - - - kdialog.h - - klistview.h -