[vlc-commits] commit: fixed libvlc loading, search for vlc in environment PATH on windows if not found in registry ( theonering )

git at videolan.org git at videolan.org
Sat Mar 13 17:53:43 CET 2010


vlc/phonon | branch: master | theonering <patrick.vonreth at gmail.com> | Thu Mar  4 21:25:30 2010 +0100| [fc48a5567d1f4f6d16c5e72a0a83cb16c2eb000d] | committer: Jean-Baptiste Kempf 

fixed libvlc loading, search for vlc in environment PATH on windows if not found in registry
(cherry picked from commit 9bd43bbbbfc9daf1eb50cfa9c398a3d2b84b900e)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/phonon.git/?a=commit;h=fc48a5567d1f4f6d16c5e72a0a83cb16c2eb000d
---

 vlc/vlcloader.cpp |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/vlc/vlcloader.cpp b/vlc/vlcloader.cpp
index f2a9184..492da5c 100644
--- a/vlc/vlcloader.cpp
+++ b/vlc/vlcloader.cpp
@@ -140,16 +140,27 @@ static QStringList findAllLibVlc()
 
     return foundVlcs;
 #elif defined(Q_OS_WIN)
-    // Read VLC version and installation directory from Windows registry
+     // Read VLC version and installation directory from Windows registry
     QSettings settings(QSettings::SystemScope, "VideoLAN", "VLC");
     QString vlcVersion = settings.value("Version").toString();
     QString vlcInstallDir = settings.value("InstallDir").toString();
     if (vlcVersion.startsWith("1.0") && !vlcInstallDir.isEmpty()) {
-        paths << vlcInstallDir + QLatin1Char('\\') + "libvlc.dll";
+        paths << vlcInstallDir + QLatin1Char('\\') + "libvlc.dll"; 
         return paths;
-    } else {
-        return QStringList();
+    }else{
+        //If nothing is found in the registry try %PATH%
+    QStringList searchPaths = QString::fromLatin1(qgetenv("PATH"))
+            .split(QLatin1Char(';'), QString::SkipEmptyParts);
+    QStringList foundVlcs;
+    foreach (const QString &sp, searchPaths) {
+        QDir dir = QDir(sp);
+        QStringList entryList = dir.entryList(QStringList() << QLatin1String("libvlc.dll"), QDir::Files);
+        foreach (const QString &entry, entryList)
+            foundVlcs << sp + QLatin1Char('\\') + entry;
     }
+    paths<<foundVlcs;
+    return paths;
+  }
 #endif
 }
 
@@ -167,7 +178,8 @@ QString vlcPath()
     foreach(path, paths) {
         vlcLibrary->setFileName(path);
 
-        if (vlcLibrary->resolve("libvlc_exception_init")) {
+        if (vlcLibrary->resolve("libvlc_get_version")) {
+            //TODO:call libvlc_get_version to test version?
             return path;
         } else {
             qDebug("Cannot resolve the symbol or load VLC library");



More information about the vlc-commits mailing list