Bug 371924

Summary: KActivities shouldn't signal currentActivityChanged() unless it actually changed.
Product: [Frameworks and Libraries] plasma-activities Reporter: Jamie Smith <smithjd15>
Component: generalAssignee: Ivan Čukić <ivan.cukic>
Status: RESOLVED WORKSFORME    
Severity: normal CC: plasma-bugs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Avoid signalling if the previous activity matches the nulluuid.

Description Jamie Smith 2016-11-01 02:36:09 UTC
KActivities::Consumer::currentActivityChanged()  signals an activity change without any corresponding change of activity.
Comment 1 Ivan Čukić 2017-01-16 11:05:04 UTC
It should not do that, there is a check in src/lib/activitiescache_p.cpp:304 for that. Do you have a way for me to replicate this?
Comment 2 Jamie Smith 2017-01-16 20:00:23 UTC
This looks like it happens at signal connection.

connect(m_activitiesConsumer, &KActivities::Consumer::currentActivityChanged, [=] {
        activityChanged(m_activitiesConsumer->currentActivity());
        Q_EMIT statusChange();
}

Commenting out "Q_EMIT statusChange()" works around a signal trigger.
Comment 3 Jamie Smith 2017-01-16 23:52:14 UTC
Created attachment 103451 [details]
Avoid signalling if the previous activity matches the nulluuid.

This patch avoids signalling that the current activity has changed when the activity it is changing from matches the nulluuid value.
Comment 4 Jamie Smith 2017-01-17 03:30:25 UTC
The attached patch does fix the issue.
Comment 5 Christoph Feck 2017-01-19 01:26:00 UTC
But is the patch also committed?
Comment 6 Jamie Smith 2017-01-19 01:28:31 UTC
Should I leave this for Ivan?
Comment 7 Christoph Feck 2017-01-19 01:41:36 UTC
Reopening the bug. Please only close if the patch is committed.
Comment 8 Jamie Smith 2017-01-19 02:04:59 UTC
OK, sorry.
Comment 9 Jamie Smith 2017-01-21 20:40:59 UTC
(In reply to Christoph Feck from comment #7)
> Reopening the bug. Please only close if the patch is committed.

Any time frame for when that may happen?
Comment 10 Ivan Čukić 2017-02-13 10:26:58 UTC
The attached patch is wrong, or I don't see the reasoning behind it.

null uuid activity is a valid activity value that applications should handle and know about. If an application gets 'current activity is null' it needs to get 'current activity is not null as well'.

If you want to ignore null uuid, you can do it downstream (like plasma mostly does).
Comment 11 Jamie Smith 2017-02-14 00:46:01 UTC
Checking for a nullid fails. If I compare the incoming activity id with currentActivity(), they match, which makes sense.

This looks like it happens each time the connecting object is constructed, which can happen when no activity change is occurring. In this situation no activity changed signal should be emitted. There's really no workaround either, it just shouldn't be emitted.
Comment 12 Ivan Čukić 2017-02-14 22:38:38 UTC
When the application starts, it does not have all the data synchronized with the activity manager (the API is completely non-blocking). For it, the current activity is null until it gets the data. When the data is received, then the signal is sent - the activity is changed from the null activity to the proper one.

Do you listen to the serviceStatusChanged signal? When it becomes Running, this should meant that the sync is complete.
Comment 13 Jamie Smith 2017-02-15 01:20:42 UTC
Checking if the service is running seems to work.