QPlugin: reorganize findPatternUnloaded and remove two bool variables
The compiler ought to figure them out, but we can just help it. Change-Id: I42eb903a916645db9900fffd16a4981ac966f982 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
parent
57960ab075
commit
f000d5672a
@ -283,10 +283,6 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
|
|||||||
/*
|
/*
|
||||||
ELF and Mach-O binaries with GCC have .qtmetadata sections. Find them.
|
ELF and Mach-O binaries with GCC have .qtmetadata sections. Find them.
|
||||||
*/
|
*/
|
||||||
bool hasMetaData = false;
|
|
||||||
char pattern[] = "qTMETADATA ";
|
|
||||||
pattern[0] = 'Q'; // Ensure the pattern "QTMETADATA" is not found in this library should QPluginLoader ever encounter it.
|
|
||||||
const ulong plen = ulong(qstrlen(pattern));
|
|
||||||
#if defined (Q_OF_ELF)
|
#if defined (Q_OF_ELF)
|
||||||
r = QElfParser().parse(filedata, r.length, library, lib);
|
r = QElfParser().parse(filedata, r.length, library, lib);
|
||||||
if (r.length == 0) {
|
if (r.length == 0) {
|
||||||
@ -307,16 +303,13 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
|
#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
|
||||||
|
|
||||||
|
char pattern[] = "qTMETADATA ";
|
||||||
|
pattern[0] = 'Q'; // Ensure the pattern "QTMETADATA" is not found in this library should QPluginLoader ever encounter it.
|
||||||
|
const ulong plen = ulong(qstrlen(pattern));
|
||||||
if (qsizetype rel = qt_find_pattern(filedata + r.pos, r.length, pattern, plen);
|
if (qsizetype rel = qt_find_pattern(filedata + r.pos, r.length, pattern, plen);
|
||||||
rel >= 0) {
|
rel >= 0) {
|
||||||
r.pos += rel;
|
const char *data = filedata + r.pos + rel;
|
||||||
hasMetaData = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if (r.pos >= 0 && hasMetaData) {
|
|
||||||
const char *data = filedata + r.pos;
|
|
||||||
QString errMsg;
|
QString errMsg;
|
||||||
QJsonDocument doc = qJsonFromRawLibraryMetaData(data, r.length, &errMsg);
|
QJsonDocument doc = qJsonFromRawLibraryMetaData(data, r.length, &errMsg);
|
||||||
if (doc.isNull()) {
|
if (doc.isNull()) {
|
||||||
@ -327,14 +320,14 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
|
|||||||
if (qt_debug_component())
|
if (qt_debug_component())
|
||||||
qWarning("Found metadata in lib %s, metadata=\n%s\n",
|
qWarning("Found metadata in lib %s, metadata=\n%s\n",
|
||||||
library.toLocal8Bit().constData(), doc.toJson().constData());
|
library.toLocal8Bit().constData(), doc.toJson().constData());
|
||||||
ret = !doc.isNull();
|
if (!doc.isNull())
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret && lib)
|
if (lib)
|
||||||
lib->errorString = QLibrary::tr("Failed to extract plugin meta data from '%1'").arg(library);
|
lib->errorString = QLibrary::tr("Failed to extract plugin meta data from '%1'").arg(library);
|
||||||
file.close();
|
return false;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void installCoverageTool(QLibraryPrivate *libPrivate)
|
static void installCoverageTool(QLibraryPrivate *libPrivate)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user