@@ -813,6 +813,36 @@ int main( int argc, char *argv[] )
813
813
}
814
814
}
815
815
816
+ // For non static builds on mac and win (static builds are not supported)
817
+ // we need to be sure we can find the qt image
818
+ // plugins. In mac be sure to look in the
819
+ // application bundle...
820
+ #ifdef Q_WS_WIN
821
+ QCoreApplication::addLibraryPath ( QApplication::applicationDirPath ()
822
+ + QDir::separator () + " qtplugins" );
823
+ #endif
824
+ #ifdef Q_OS_MACX
825
+ // IMPORTANT: do before Qt uses any plugins, e.g. before loading splash screen
826
+ QString myPath ( QCoreApplication::applicationDirPath ().append ( " /../PlugIns" ) );
827
+ // Check if it contains a standard Qt-specific plugin subdirectory
828
+ if ( !QFile::exists ( myPath + " /imageformats" ) )
829
+ {
830
+ // We are either running from build dir bundle, or launching binary directly.
831
+ // Use system Qt plugins, since they are not bundled.
832
+ // An app bundled with QGIS_MACAPP_BUNDLE=0 will still have Plugins/qgis in it
833
+ myPath = QT_PLUGINS_DIR;
834
+ }
835
+
836
+ // First clear the plugin search paths so we can be sure only plugins we define
837
+ // are being used. Note: this strips QgsApplication::pluginPath()
838
+ QStringList myPathList;
839
+ QCoreApplication::setLibraryPaths ( myPathList );
840
+
841
+ QgsDebugMsg ( QString ( " Adding Mac QGIS and Qt plugins dirs to search path: %1" ).arg ( myPath ) );
842
+ QCoreApplication::addLibraryPath ( QgsApplication::pluginPath () );
843
+ QCoreApplication::addLibraryPath ( myPath );
844
+ #endif
845
+
816
846
// set up splash screen
817
847
QString mySplashPath ( QgsCustomization::instance ()->splashPath () );
818
848
QPixmap myPixmap ( mySplashPath + QString ( " splash.png" ) );
@@ -828,58 +858,6 @@ int main( int argc, char *argv[] )
828
858
mypSplash->show ();
829
859
}
830
860
831
- // For non static builds on mac and win (static builds are not supported)
832
- // we need to be sure we can find the qt image
833
- // plugins. In mac be sure to look in the
834
- // application bundle...
835
- #ifdef Q_WS_WIN
836
- QCoreApplication::addLibraryPath ( QApplication::applicationDirPath ()
837
- + QDir::separator () + " qtplugins" );
838
- #endif
839
- #ifdef Q_OS_MACX
840
- // qDebug("Adding qt image plugins to plugin search path...");
841
- CFURLRef myBundleRef = CFBundleCopyBundleURL ( CFBundleGetMainBundle () );
842
- CFStringRef myMacPath = CFURLCopyFileSystemPath ( myBundleRef, kCFURLPOSIXPathStyle );
843
- const char *mypPathPtr = CFStringGetCStringPtr ( myMacPath, CFStringGetSystemEncoding () );
844
- CFRelease ( myBundleRef );
845
- CFRelease ( myMacPath );
846
- QString myPath ( mypPathPtr );
847
- // if we are not in a bundle assume that the app is built
848
- // as a non bundle app and that image plugins will be
849
- // in system Qt frameworks. If the app is a bundle
850
- // lets try to set the qt plugin search path...
851
- QFileInfo myInfo ( myPath );
852
- if ( myInfo.isBundle () )
853
- {
854
- // First clear the plugin search paths so we can be sure
855
- // only plugins from the bundle are being used
856
- QStringList myPathList;
857
- QCoreApplication::setLibraryPaths ( myPathList );
858
- // Now set the paths inside the bundle
859
- myPath += " /Contents/Plugins" ;
860
- QCoreApplication::addLibraryPath ( myPath );
861
- if ( QgsApplication::isRunningFromBuildDir () || QGIS_MACAPP_BUNDLE == 0 )
862
- {
863
- QCoreApplication::addLibraryPath ( QT_PLUGINS_DIR );
864
- }
865
- // next two lines should not be needed, testing only
866
- #if 0
867
- QCoreApplication::addLibraryPath( myPath + "/imageformats" );
868
- QCoreApplication::addLibraryPath( myPath + "/sqldrivers" );
869
- foreach ( myPath, myApp.libraryPaths() )
870
- {
871
- qDebug( "Path:" + myPath.toLocal8Bit() );
872
- }
873
- qDebug( "Added %s to plugin search path", qPrintable( myPath ) );
874
- QList<QByteArray> myFormats = QImageReader::supportedImageFormats();
875
- for ( int x = 0; x < myFormats.count(); ++x )
876
- {
877
- qDebug( "Format: " + myFormats[x] );
878
- }
879
- #endif
880
- }
881
- #endif
882
-
883
861
QgisApp *qgis = new QgisApp ( mypSplash, myRestorePlugins ); // "QgisApp" used to find canonical instance
884
862
qgis->setObjectName ( " QgisApp" );
885
863
0 commit comments