Bug 189401

Summary: two AWAY commands are sent to the server with /away and /back
Product: [Applications] konversation Reporter: larvid
Component: generalAssignee: Konversation Developers <konversation-devel>
Status: RESOLVED FIXED    
Severity: normal CC: hein
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 187307    
Attachments: fixes the bug by adding checks

Description larvid 2009-04-11 20:53:10 UTC
Version:           1.1.75+ build 3400 (using KDE 4.2.2)
Compiler:          gcc 4.3.3 
OS:                Linux
Installed from:    Compiled From Sources

When using /away and /back in order to set/unset my status on IRC as away, two AWAY commands are sent to the server instead of just one.

If I once type "/away afk", Konversation will display:

[Away] You are now marked as being away.
[Away] You are now marked as being away.

And in the raw log:

<< AWAY :afk
<< AWAY :Gone away for now


When typing "/back" in order to unset the away status, Konversation displays:

[Away] You are no longer marked as being away.
[Away] You are not marked as being away.

And the raw log:

<< AWAY
<< AWAY
Comment 1 Travis McHenry 2009-04-17 07:31:47 UTC
Created attachment 32883 [details]
fixes the bug by adding checks

Took me awhile to track this down, I made notes to help so I'll just copy those to explain what I saw/did.

on /away:
setAway emits awayState
connect(server, SIGNAL(awayState(bool)), this, SIGNAL(connectionChangedAwayState(bool)));
connect(m_connectionManager, SIGNAL(connectionChangedAwayState(bool)), m_awayManager, SLOT(updateGlobalAwayAction(bool)));
updateGlobalAwayAction runs: awayAction->setChecked(true);
connect(awayAction, SIGNAL(toggled(bool)), KonversationApplication::instance()->getAwayManager(), SLOT(toggleGlobalAway(bool)));
toggleGlobalAway runs: requestAll(un)Away();
which calls setAway again.

Explanation: When the checkbox is updated with the new state, it runs the action as if the user asked for it.

Solution: Add checks to toggleGlobalAway.
Comment 2 Eike Hein 2009-04-17 20:39:25 UTC
Fixed in SVN rev 955470 (using a simpler approach that just takes care of the underlying porting fallout - the behavior of the toggled(bool) signal for toggle actions has effectively changed between KDE 3 and 4; triggered(bool) is the right one to use here now).