D25984: Load translations

Friedrich W. H. Kossebau noreply at phabricator.kde.org
Sun Dec 15 16:14:58 GMT 2019


kossebau added a comment.


  In D25984#578296 <https://phabricator.kde.org/D25984#578296>, @broulik wrote:
  
  > We don't link against Kirigami, so the startup routine stuff doesn't apply?
  
  
  `Q_COREAPP_STARTUP_FUNCTION` generates a static struct in the compiled code, whose constructor will be invoked on loading the lib which bundles that obect code, and the constructor does the registration call (which then also cares for directly executing the method if already passed QApp construction phase). See below for how exactly.
  
  So at least to what I "know" being loaded in a lib only later at runtime still should result in the call being triggered, as also at that time any static objects will be constructed/init during lib load.
  
  > And we're way after the QCoreApp constructor at this point.
  
  Yes, but that is something `qAddPreRoutine` deals with, by in that case then also executing the method itself:
  
    void qAddPreRoutine(QtStartUpFunction p)
    {
        QStartUpFuncList *list = preRList();
        if (!list)
            return;
        if (QCoreApplication::instance())
            p();
        // Due to C++11 parallel dynamic initialization, this can be called
        // from multiple threads.
        QMutexLocker locker(&globalRoutinesMutex);
        list->prepend(p); // in case QCoreApplication is re-created, see qt_call_pre_routines
    }
  
  See how `qAddPreRoutine` code is generated  by `Q_COREAPP_STARTUP_FUNCTION`:
  
    #define Q_COREAPP_STARTUP_FUNCTION(AFUNC) \
        static void AFUNC ## _ctor_function() {  \
            qAddPreRoutine(AFUNC);        \
        }                                 \
        Q_CONSTRUCTOR_FUNCTION(AFUNC ## _ctor_function)
  
  with `Q_CONSTRUCTOR_FUNCTION` being:
  
    #ifndef Q_CONSTRUCTOR_FUNCTION
    # define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
        namespace { \
        static const struct AFUNC ## _ctor_class_ { \
            inline AFUNC ## _ctor_class_() { AFUNC(); } \
        } AFUNC ## _ctor_instance_; \
        }
    # define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC)
    #endif

REPOSITORY
  R169 Kirigami

REVISION DETAIL
  https://phabricator.kde.org/D25984

To: broulik, #kirigami, #frameworks, kossebau, aacid, sitter
Cc: plasma-devel, fbampaloukas, GB_2, domson, dkardarakos, ngraham, apol, ahiemstra, davidedmundson, mart, hein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20191215/7df7025c/attachment.html>


More information about the Plasma-devel mailing list