From 727787abaf6761712dba2a403be5dd1cab8d60b6 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sun, 17 Mar 2019 17:13:32 +0100 Subject: [PATCH] initializing QT_PLUGIN_PATH before main --- playground/inputpanel/inputpanel.pro | 2 -- playground/inputpanel/main.cpp | 6 ---- support/SkinnyPlugin.cpp | 46 ++++++++++++++++------------ 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/playground/inputpanel/inputpanel.pro b/playground/inputpanel/inputpanel.pro index 499ddb20..a3bb0c0d 100644 --- a/playground/inputpanel/inputpanel.pro +++ b/playground/inputpanel/inputpanel.pro @@ -2,7 +2,5 @@ include( $${PWD}/../playground.pri ) TARGET = inputpanel -DEFINES += PLUGIN_PATH=$$clean_path( $$QSK_OUT_ROOT/plugins ) - SOURCES += \ main.cpp diff --git a/playground/inputpanel/main.cpp b/playground/inputpanel/main.cpp index df99a7a0..faf56fe2 100644 --- a/playground/inputpanel/main.cpp +++ b/playground/inputpanel/main.cpp @@ -22,9 +22,6 @@ #include #include -#define STRINGIFY( x ) #x -#define STRING( x ) STRINGIFY( x ) - static inline QString nativeLocaleString( const QLocale& locale ) { switch ( locale.language() ) @@ -287,10 +284,7 @@ int main( int argc, char* argv[] ) QskObjectCounter counter( true ); #endif -#if 1 qputenv( "QT_IM_MODULE", "skinny" ); - qputenv( "QT_PLUGIN_PATH", STRING( PLUGIN_PATH ) ); -#endif QGuiApplication app( argc, argv ); diff --git a/support/SkinnyPlugin.cpp b/support/SkinnyPlugin.cpp index 22fdaa59..83a94e5e 100644 --- a/support/SkinnyPlugin.cpp +++ b/support/SkinnyPlugin.cpp @@ -3,41 +3,46 @@ * This file may be used under the terms of the 3-clause BSD License *****************************************************************************/ -#if defined( ENSURE_SKINS ) - -#include -#include -#include -#include - -#endif - #if defined( PLUGIN_PATH ) -#include #include #include #define STRINGIFY(x) #x #define STRING(x) STRINGIFY(x) -#endif - -static void initPlugins() +static int initPluginPath() { -#if defined( PLUGIN_PATH ) const char env[] = "QT_PLUGIN_PATH"; QByteArray value = qgetenv( env ); - if ( !value.isEmpty() && QChar( value[ value.size() - 1 ] ) != QDir::listSeparator() ) - value += QDir::listSeparator(); + if ( !value.isEmpty() ) + { + if ( QChar( value.at( value.size() - 1 ) ) != QDir::listSeparator() ) + value += QDir::listSeparator(); + } value += STRING( PLUGIN_PATH ); - qputenv( "QT_PLUGIN_PATH", value ); -#endif + qputenv( env, value ); + return 0; +} + +// some plugins are loaded before entering QCoreApplication +static bool pluginPath = initPluginPath(); + +#endif // PLUGIN_PATH #if defined( ENSURE_SKINS ) + +#include +#include +#include +#include +#include + +static void initSkins() +{ if ( qskSkinManager->skinNames().isEmpty() ) { using namespace std; @@ -52,7 +57,8 @@ static void initPlugins() cout << "Couldn't find skin plugins, adding some manually." << endl; } -#endif } -Q_COREAPP_STARTUP_FUNCTION( initPlugins ) +Q_COREAPP_STARTUP_FUNCTION( initSkins ) + +#endif // ENSURE_SKINS