Bug 371924 - KActivities shouldn't signal currentActivityChanged() unless it actually changed.
Summary: KActivities shouldn't signal currentActivityChanged() unless it actually chan...
Status: RESOLVED WORKSFORME
Alias: None
Product: plasma-activities
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Ivan Čukić
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-01 02:36 UTC by Jamie Smith
Modified: 2017-02-15 03:51 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Avoid signalling if the previous activity matches the nulluuid. (1.14 KB, patch)
2017-01-16 23:52 UTC, Jamie Smith
Details

Note You need to log in before you can comment on or make changes to this bug.
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.