OSDN Git Service

drop QLibrary methods taking version as argument
authorIvailo Monev <xakepa10@gmail.com>
Sun, 12 Jun 2022 14:26:45 +0000 (17:26 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 12 Jun 2022 14:26:45 +0000 (17:26 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/plugin/qlibrary.cpp
src/core/plugin/qlibrary.h

index 5df6f4f..fb5f90b 100644 (file)
@@ -201,7 +201,7 @@ static bool qt_unix_query(const QString &library, uint *version, QLibraryPrivate
 #endif // QT_NO_PLUGIN_CHECK
 
 
-static QString qt_find_library(const QString &fileName, const QString &version)
+static QString qt_find_library(const QString &fileName)
 {
     QFileSystemEntry fsEntry(fileName);
 
@@ -212,8 +212,8 @@ static QString qt_find_library(const QString &fileName, const QString &version)
     else
         path += QLatin1Char('/');
 
-    QStringList suffixes;
-    suffixes << QLatin1String("");
+    static const QStringList suffixes = QStringList()
+        << QLatin1String("") << QLatin1String(".so");
     QStringList prefixes;
     prefixes << QLatin1String("") << QLatin1String("lib");
 
@@ -223,12 +223,6 @@ static QString qt_find_library(const QString &fileName, const QString &version)
         }
     }
 
-    if (!version.isEmpty()) {
-        suffixes << QString::fromLatin1(".so.%1").arg(version);
-    } else {
-        suffixes << QLatin1String(".so");
-    }
-
     foreach (const QString &prefix, prefixes) {
         foreach (const QString &suffix, suffixes) {
             if (!prefix.isEmpty() && name.startsWith(prefix))
@@ -485,7 +479,7 @@ QLibrary::QLibrary(QObject *parent)
 
     \sa fileName()
  */
-QLibrary::QLibrary(const QStringfileName, QObject *parent)
+QLibrary::QLibrary(const QString &fileName, QObject *parent)
     : QObject(parent),
     d_ptr(new QLibraryPrivate())
 {
@@ -493,42 +487,6 @@ QLibrary::QLibrary(const QString& fileName, QObject *parent)
 }
 
 /*!
-    Constructs a library object with the given \a parent that will
-    load the library specified by \a fileName and major version
-    number \a verNum.
-
-    We recommend omitting the file's suffix in \a fileName, since
-    QLibrary will automatically look for the file with the appropriate
-    suffix in accordance with the platform, e.g. ".so" on Unix.
-
-    \sa fileName()
-*/
-QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent)
-    : QObject(parent),
-    d_ptr(new QLibraryPrivate())
-{
-    setFileNameAndVersion(fileName, verNum);
-}
-
-/*!
-    Constructs a library object with the given \a parent that will
-    load the library specified by \a fileName and full version
-    number \a version.
-
-    We recommend omitting the file's suffix in \a fileName, since
-    QLibrary will automatically look for the file with the appropriate
-    suffix in accordance with the platform, e.g. ".so" on Unix.
-
-    \sa fileName()
- */
-QLibrary::QLibrary(const QString& fileName, const QString &version, QObject *parent)
-    : QObject(parent),
-    d_ptr(new QLibraryPrivate())
-{
-    setFileNameAndVersion(fileName, version);
-}
-
-/*!
     Destroys the QLibrary object.
 
     Unless unload() was called explicitly, the library stays in memory
@@ -569,39 +527,8 @@ QLibrary::~QLibrary()
 
 void QLibrary::setFileName(const QString &fileName)
 {
-    setFileNameAndVersion(fileName, QString());
-}
-
-QString QLibrary::fileName() const
-{
-    return d_ptr->fileName;
-}
-
-/*!
-    \fn void QLibrary::setFileNameAndVersion(const QString &fileName, int versionNumber)
-
-    Sets the fileName property and major version number to \a fileName
-    and \a versionNumber respectively.
-
-    \sa setFileName()
-*/
-void QLibrary::setFileNameAndVersion(const QString &fileName, int verNum)
-{
-    setFileNameAndVersion(fileName, verNum >= 0 ? QString::number(verNum) : QString());
-}
-
-/*!
-    \since 4.4
-
-    Sets the fileName property and full version number to \a fileName
-    and \a version respectively.
-
-    \sa setFileName()
-*/
-void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &version)
-{
     // if the library path is not the same it may very well be library with different symbols
-    const QString librarymatch = qt_find_library(fileName, version);
+    const QString librarymatch = qt_find_library(fileName);
     QMutexLocker locker(qGlobalLibraryMutex());
     QLibraryCleanup* loadedlibraries = qGlobalLibraryList();
     for (int i = 0; i < loadedlibraries->size(); i++) {
@@ -619,6 +546,11 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver
     d_ptr->fileName = librarymatch;
 }
 
+QString QLibrary::fileName() const
+{
+    return d_ptr->fileName;
+}
+
 /*!
     Returns the address of the exported symbol \a symbol. The library is
     loaded if necessary. The function returns 0 if the symbol could
index ecfcb2b..b89b5ee 100644 (file)
@@ -45,9 +45,7 @@ public:
     Q_DECLARE_FLAGS(LoadHints, LoadHint)
 
     explicit QLibrary(QObject *parent = nullptr);
-    explicit QLibrary(const QString& fileName, QObject *parent = nullptr);
-    explicit QLibrary(const QString& fileName, int verNum, QObject *parent = nullptr);
-    explicit QLibrary(const QString& fileName, const QString &version, QObject *parent = nullptr);
+    explicit QLibrary(const QString &fileName, QObject *parent = nullptr);
     ~QLibrary();
 
     void *resolve(const char *symbol);
@@ -61,8 +59,6 @@ public:
     void setFileName(const QString &fileName);
     QString fileName() const;
 
-    void setFileNameAndVersion(const QString &fileName, int verNum);
-    void setFileNameAndVersion(const QString &fileName, const QString &version);
     QString errorString() const;
 
     void setLoadHints(LoadHints hints);