[libinput] Ensure Event::device returns a proper Device
ClosedPublic

Authored by graesslin on Feb 1 2018, 5:06 PM.

Details

Summary

This fixes a problem when a Device added and another event on the Device
are queued together. In that case the second event would not get the
Device set as it's not yet created.

This change ensures that when accessing device the pointer will be
updated.

BUG: 389674
FIXED-IN: 5.12.1

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin created this revision.Feb 1 2018, 5:06 PM
Restricted Application added a project: KWin. · View Herald TranscriptFeb 1 2018, 5:06 PM
Restricted Application added subscribers: kwin, plasma-devel. · View Herald Transcript
graesslin requested review of this revision.Feb 1 2018, 5:06 PM
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptFeb 1 2018, 5:06 PM
fvogt added a comment.Feb 1 2018, 6:54 PM

Now you can remove the initial setting of m_device as well.

Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptFeb 1 2018, 6:54 PM

Now you can remove the initial setting of m_device as well.

I thought about it while doing the change. I decided against it for the following reasons:

  • it would need to be inited with null instead
  • the norm is not having this problem, the switch event is an exception
  • device would have to lose the const-ness, the const_cast hack is in my opinion only a valid solution for exceptions, for the standard case it would have to be changed.
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptFeb 1 2018, 7:07 PM
fvogt added a comment.Feb 1 2018, 7:15 PM

Now you can remove the initial setting of m_device as well.

I thought about it while doing the change. I decided against it for the following reasons:

  • it would need to be inited with null instead

Alternatively just call device() once explicitly in the constructor to avoid code duplication.
That way the lazyness of device() is lost, but that's not a goal anyway.

  • the norm is not having this problem, the switch event is an exception

It's not, this can happen to literally any event if they get queued together.

  • device would have to lose the const-ness, the const_cast hack is in my opinion only a valid solution for exceptions, for the standard case it would have to be changed.

Just set m_device as mutable instead, that's what it's intended for.

Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptFeb 1 2018, 7:15 PM
graesslin updated this revision to Diff 26362.Feb 2 2018, 5:52 AM

Make m_device mutable and always lazy load it.

Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptFeb 2 2018, 5:52 AM
Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptFeb 2 2018, 6:59 AM
avaragic accepted this revision.Feb 2 2018, 8:36 AM
This revision is now accepted and ready to land.Feb 2 2018, 8:36 AM
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptFeb 2 2018, 8:36 AM
fvogt accepted this revision.Feb 3 2018, 1:34 PM

Tested, works!

Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptFeb 3 2018, 1:34 PM
fvogt added a comment.Feb 3 2018, 1:34 PM

I'm actually in favor of a tar respin for 5.12.0 in this case. What do you think?

Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptFeb 3 2018, 1:34 PM
graesslin added a subscriber: bshah.Feb 3 2018, 2:01 PM

I'm actually in favor of a tar respin for 5.12.0 in this case. What do you think?

I would not have asked for it, but I agree. @bshah can you please take care of it?

Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptFeb 3 2018, 2:01 PM
bshah added a comment.Feb 3 2018, 2:16 PM

I would not have asked for it, but I agree. @bshah can you please take care of it?

Yeah give me half an hour

Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptFeb 3 2018, 2:16 PM
bshah added a comment.Feb 3 2018, 2:26 PM

Ergh, can you commit it though?

Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptFeb 3 2018, 2:26 PM
This revision was automatically updated to reflect the committed changes.
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptFeb 3 2018, 3:03 PM