Bug 228795 - script added to autostart cannot be configured to run at shutdown
Summary: script added to autostart cannot be configured to run at shutdown
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_autostart (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Laurent Montel
URL:
Keywords: investigated
: 171139 310629 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-02-27 19:21 UTC by Peter Gantner
Modified: 2012-11-25 07:50 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.4
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Gantner 2010-02-27 19:21:12 UTC
Version:           1.0 (using KDE 4.4.0)
Compiler:          gcc (Gentoo 4.3.4 p1.0, pie-10.1.5) 4.3.4  
OS:                Linux
Installed from:    Gentoo Packages

 - open systemsettings
 - go to Advanced
 - go to Autostart
 - click "add script"
 - select a script, leave "create as symlink" checked
 - click OK
 --> script is aded to the "Scripts listing"

 - in the scripts listing in the "Run On" column, select "shutdown"
 - Click "Overview" button to exit Autostart settings
 - re-enter "Autostart" settings
--> script is still in the listing, but set to run on startup.

Effects in ~/.kde4/:
 - symlink to the script file is correctly created in ~/.kde4/Autostart
 - if it does not exist, ~/.kde4/shutdown directory is created
 - *but* symlink is never moved to the ~/.kde4/shutdown directory
Comment 1 Peter Gantner 2010-02-27 19:22:29 UTC
for got one thing:

If I later move the symlink from ~/.kde4/Autostart to ~/.kde4/shutdown, the Autostart settings shows it correctly configured to run on shutdown.
Comment 2 brunomcl 2011-06-11 05:40:39 UTC
I'd like to confirm this bug in KDE 4.6.3 "release 4", exactly as the OP described.
Comment 3 S. Christian Collins 2011-07-04 19:01:49 UTC
I can confirm this bug exists in KDE 4.6.4 as well.  Additionally, setting a script to run on shutdown will often move the wrong script to the shutdown folder!
Comment 4 S. Christian Collins 2011-07-04 19:30:49 UTC
I figured out what is happening:
1) When a script is set to "Startup", it is to be placed in ~/.kde/Autostart.  When a script is set to "Shutdown", it is to be placed in ~/.kde/shutdown.
2) When you select one of these options, the KDE autostart module is moving the script that is currently highlighted (blue by default) regardless of which script's combo box you have just accessed.

So, the current workaround is to click on the script's entry so it is highlighted in blue, then select its startup option from the combo box.

BTW: I didn't test with the "Pre-KDE Startup" option, but I'd assume it's the same story there.
Comment 5 Mikiya Okuno 2012-10-27 23:31:08 UTC
I face the same problem too.

I figure out the problem. This happens when there are more than one items under the "Script File". Every time when manipulate an item which does not has the focus, the focused item is moved! So item selection is wrong.

void Autostart::slotChangeStartup( int index )
{
    if ( widget->listCMD->currentItem() == 0 )
        return;
    ScriptStartItem* entry = dynamic_cast<ScriptStartItem*>( widget->listCMD->currentItem() );
    if ( entry )
    {
        entry->setPath(m_paths.value(index));
        if ( ( index != 0 ) && !entry->fileName().path().endsWith( ".sh" ))
            KMessageBox::information( this, i18n( "Only files with “.sh” extensions are allowed for setting up the environment." ) );
    }
}

QListWidget::currentItem() does not return the item which is manipulated, but returns the item which has the focus. I don't know what is the correct logic to select the item though.

Cheers!
Comment 6 Jekyll Wu 2012-11-10 05:42:17 UTC
Thanks for the helpful steps and investigation. I will see whether I can do something to fix this :)
Comment 7 Jekyll Wu 2012-11-10 06:01:15 UTC
Git commit 044c91d6f6adf3e3d935c652c659f5346c6c2011 by Jekyll Wu.
Committed on 10/11/2012 at 05:40.
Pushed by jekyllwu into branch 'KDE/4.9'.

Make sure the right item is operated on when changing startup type

The problem was the "current" item was sometime not the one you would
have expected when changing the startup type of item A:

  * it could be "none"
  * it could be the previous "current" item

The fix is a little hacky, but better than none.
FIXED-IN: 4.9.4

M  +8    -7    kcontrol/autostart/autostart.cpp
M  +1    -1    kcontrol/autostart/autostart.h
M  +8    -1    kcontrol/autostart/autostartitem.cpp
M  +11   -1    kcontrol/autostart/autostartitem.h

http://commits.kde.org/kde-workspace/044c91d6f6adf3e3d935c652c659f5346c6c2011
Comment 8 Jekyll Wu 2012-11-10 06:11:09 UTC
*** Bug 171139 has been marked as a duplicate of this bug. ***
Comment 9 S. Christian Collins 2012-11-10 06:17:22 UTC
Thanks for the fix, Jekyll!
Comment 10 Mikiya Okuno 2012-11-10 08:32:34 UTC
Jekyll,

Thank you for the fix! The fix looks reasonable.
Comment 11 Jekyll Wu 2012-11-25 07:50:40 UTC
*** Bug 310629 has been marked as a duplicate of this bug. ***