Skip to content

Commit

Permalink
don't load plugin paths from default qt dir on win/mac unless forced …
Browse files Browse the repository at this point in the history
…via env
  • Loading branch information
Justin Karneges committed Aug 14, 2012
1 parent 2e50cab commit 2d74a49
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions admin/build/devconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if [ "$platform" == "win" ]; then
echo "export PATH=/c/mingw64/bin:\$PATH" >> $build_base/devenv
fi
echo "export PATH=$mqtdir/bin:$deps_base/$qca_win_dir/$target_arch/bin:$deps_base/$zlib_win_dir/$target_arch/bin:$deps_base/$aspell_win_dir/$target_arch/bin:$deps_base/$openssl_win_dir/$target_arch/bin:$deps_base/$gstbundle_win_dir/$target_arch/bin:\$PATH" >> $build_base/devenv
echo "export QT_PLUGIN_PATH=$deps_base/$qca_win_dir/$target_arch/plugins" >> $build_base/devenv
echo "export QT_PLUGIN_PATH=$mqtdir/plugins:$deps_base/$qca_win_dir/$target_arch/plugins" >> $build_base/devenv
echo "export PSI_MEDIA_PLUGIN=$deps_base/$psimedia_win_dir/$target_arch/plugins/gstprovider.dll" >> $build_base/devenv
else
export DYLD_FRAMEWORK_PATH=$QTDIR/lib:$deps_base/$qca_mac_dir/lib:$deps_base/$growl_dir/Framework
Expand All @@ -80,6 +80,6 @@ else
touch $build_base/devenv
echo "export DYLD_LIBRARY_PATH=$deps_base/$gstbundle_mac_dir/$target_arch/lib:\$PATH" >> $build_base/devenv
echo "export DYLD_FRAMEWORK_PATH=$QTDIR/lib:$deps_base/$qca_mac_dir/lib:$deps_base/$growl_dir/Framework" >> $build_base/devenv
echo "export QT_PLUGIN_PATH=$deps_base/$qca_mac_dir/$target_arch/plugins" >> $build_base/devenv
echo "export QT_PLUGIN_PATH=$QTDIR/plugins:$deps_base/$qca_mac_dir/$target_arch/plugins" >> $build_base/devenv
echo "export PSI_MEDIA_PLUGIN=$deps_base/$psimedia_mac_dir/$target_arch/plugins/libgstprovider.dylib" >> $build_base/devenv
fi
33 changes: 33 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <QFileInfo>
#include <QProcess>
#include <QTime>
#include <QLibraryInfo>

#include <stdlib.h>
#include <time.h>
Expand Down Expand Up @@ -447,6 +448,30 @@ void psiMessageOutput(QtMsgType type, const char *msg)
}
}

QStringList getQtPluginPathEnvVar()
{
QStringList out;

QByteArray val = qgetenv("QT_PLUGIN_PATH");
if(!val.isEmpty())
{
#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
QLatin1Char pathSep(';');
#else
QLatin1Char pathSep(':');
#endif
QStringList paths = QString::fromLatin1(val).split(pathSep, QString::SkipEmptyParts);
foreach(const QString &path, paths)
{
QString canonicalPath = QDir(path).canonicalPath();
if(!canonicalPath.isEmpty() && !out.contains(canonicalPath))
out += canonicalPath;
}
}

return out;
}

int main(int argc, char *argv[])
{
// If Psi runs as uri handler the commandline might contain
Expand All @@ -473,6 +498,14 @@ int main(int argc, char *argv[])
#endif
}

#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
// remove qt's own plugin path on these platforms, to enable safe
// distribution
QString defaultPluginPath = QLibraryInfo::location(QLibraryInfo::PluginsPath);
if(!getQtPluginPathEnvVar().contains(defaultPluginPath))
QCoreApplication::removeLibraryPath(defaultPluginPath);
#endif

// NOTE: Qt 4.5 compatibility note: please don't move this call.
// instead, upgrade to QCA 2.0.2, which fixes the bug in the right
// place.
Expand Down

0 comments on commit 2d74a49

Please sign in to comment.