Setup QQmlEngine only once in QmlObject
ClosedPublic

Authored by broulik on Dec 3 2017, 3:49 PM.

Details

Summary

setupBindings is called for every QmlObject created and installs various bits on the QQmlEngine, such as a network access manager, a theme icon provider, etc. However, since we use a shared QQmlEngine in various places, most of this needs to be done only once.

This splits setupBindings into a setupContext method for setting up the localized context needed for every instance and a setupEngine static function that setups an engine. A fourth constructor is added that allows to influence the setup behavior. While at it, delegating constructors are used doing both to not change behavior.

Test Plan

I now have the same thing done only twice instead of like 26 times. Once when the shared engine is created and another time (setupbindings in corebindingsplugin in plasma which probably can go?)

  • Verified translations still work

Diff Detail

Repository
R296 KDeclarative
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Dec 3 2017, 3:49 PM
Restricted Application added projects: Plasma, Frameworks. · View Herald TranscriptDec 3 2017, 3:49 PM
Restricted Application added subscribers: Frameworks, plasma-devel. · View Herald Transcript
broulik requested review of this revision.Dec 3 2017, 3:49 PM
hein added subscribers: mart, hein.Dec 3 2017, 3:54 PM

Looks good to me, but @mart needs to have a look too.

mart requested changes to this revision.Dec 3 2017, 5:37 PM
mart added inline comments.
src/kdeclarative/qmlobject.h
72

this shouldn't be necessary?

qmoobject will do things engine-wise, the qmlsharedengine subclass will always do things context-wise without new public constructors?

This revision now requires changes to proceed.Dec 3 2017, 5:37 PM
davidedmundson added inline comments.
src/kdeclarative/qmlobject.h
72

The problem being solved is that QQmlObjectSharedEngine inherits QQmlObject
that needs a constructor that doesn't do engine things

It could be protected though.

mart added inline comments.Dec 3 2017, 7:54 PM
src/kdeclarative/qmlobject.h
72

what about a different ctor which does that, but without exposing that enum?

broulik added inline comments.Dec 4 2017, 9:30 AM
src/kdeclarative/qmlobject.h
72

What signature should I use for the constructor?

broulik updated this revision to Diff 28691.Mar 5 2018, 11:00 AM
broulik edited the test plan for this revision. (Show Details)
  • Use protected constructor with pseudo argument instead of flags
mart accepted this revision.Mar 5 2018, 12:59 PM

i like it now

This revision is now accepted and ready to land.Mar 5 2018, 12:59 PM
This revision was automatically updated to reflect the committed changes.