Fix MSVC build: do not require full std::vector type to be export by using a member reference
ClosedPublic

Authored by tilladam on Apr 25 2020, 2:08 PM.

Details

Reviewers
dfaure
Group Reviewers
Ruqola
Summary

MSVC attemps to emit the full std::vector type because the class is exported and cannot fully instantiate it because the payload type is not copyable. Use a member reference instead so that the full type is only needed in the implementation.

Diff Detail

Repository
R865 Ruqola
Lint
Lint Skipped
Unit
Unit Tests Skipped
tilladam requested review of this revision.Apr 25 2020, 2:08 PM
tilladam created this revision.
mlaurent added a subscriber: mlaurent.

I add david as reviewer it's his code I think :)

dfaure requested changes to this revision.Apr 25 2020, 5:04 PM

Wow a patch by Till Adam, it feels like the old days again :-)

I remember the problem with MSVC instanciating templates fully, but RunningAnimatedImage is defined in the header so it has access to it, no? I don't follow the logic of "so that the full type is only needed in the implementation".

Would it help to disable copying of MessageDelegateHelperImage so that MSVC doesn't attempt to generate code that copies that vector? If the ref helps, I'm thinking this might be the problem...

src/widgets/room/delegate/messagedelegatehelperimage.cpp
41 ↗(On Diff #81175)

Doesn't this create a reference to a temporary?

This revision now requires changes to proceed.Apr 25 2020, 5:04 PM
tilladam updated this revision to Diff 81186.Apr 25 2020, 5:33 PM

Yep, disabling the copyability of MessageDelegateHelperImage also helps, because the vector doesn't need to be copyable anymore. Better solution, indeed.

dfaure accepted this revision.Apr 25 2020, 5:53 PM
This revision is now accepted and ready to land.Apr 25 2020, 5:53 PM
tilladam closed this revision.Apr 25 2020, 6:12 PM
tilladam added inline comments.
src/widgets/room/delegate/messagedelegatehelperimage.cpp
41 ↗(On Diff #81175)

Ah, right, because it uses the move ctor, right?

dfaure added inline comments.Apr 25 2020, 8:58 PM
src/widgets/room/delegate/messagedelegatehelperimage.cpp
41 ↗(On Diff #81175)

Hmm, no, because the member was a ref, and it was initialized with a default-constructed temporary here. But well, it didn't crash for you so I'm not 100% sure what was happening here.