- 
    Bug 
- 
    Resolution: Fixed
- 
    P2: Important 
- 
    None
- 
    5.15.2
- 
    None
- 
        
- 
        22e967c3049608f82abd32a0beb0b4b36ee134bf
When I tried to use Q_COREAPP_STARTUP_FUNCTION(test_qAddPreRoutine) in the Qt platforms plugin, I found that the test_qAddPreRoutine function would be called twice.
#include <qpa/qplatformintegrationplugin.h> #include <qpa/qplatformintegration.h> #include <private/qgenericunixeventdispatcher_p.h> #include <QCoreApplication> #include <QDebug> static void test_qAddPreRoutine() { qDebug() << Q_FUNC_INFO; } Q_COREAPP_STARTUP_FUNCTION(test_qAddPreRoutine) class Test : public QPlatformIntegration { public: QPlatformBackingStore *createPlatformBackingStore(QWindow *) const override { return nullptr; } QPlatformWindow *createPlatformWindow(QWindow *window) const override { return nullptr; } QAbstractEventDispatcher *createEventDispatcher() const override { return createUnixEventDispatcher(); } }; class TestPlugin : public QPlatformIntegrationPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "test.json") public: QPlatformIntegration *create(const QString&, const QStringList&, int &, char **) override { return new Test(); } }; #include "main.moc"
If application load the “test” platform plugin, can get two lines output:
log
void test_qAddPreRoutine()
void test_qAddPreRoutine()
| For Gerrit Dashboard: QTBUG-90341 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V | 
| 330162,29 | fix: The QtStartUpFunction function may be called repeatedly | dev | qt/qtbase | Status: MERGED | +2 | 0 | 
| 345178,4 | fix: The QtStartUpFunction function may be called repeatedly | 6.0 | qt/qtbase | Status: MERGED | +2 | 0 | 
| 345179,4 | fix: The QtStartUpFunction function may be called repeatedly | 6.1 | qt/qtbase | Status: MERGED | +2 | 0 | 
| 345522,3 | CMake: Fix tst_qaddpreroutine to work with static builds | 6.0 | qt/qtbase | Status: MERGED | +2 | 0 | 
| 345523,3 | CMake: Fix tst_qaddpreroutine to work with static builds | dev | qt/qtbase | Status: MERGED | +2 | 0 | 
| 345603,3 | CMake: Fix tst_qaddpreroutine to work with static builds | 6.1 | qt/qtbase | Status: MERGED | +2 | 0 |