Plugin metadata is now updated in setFileName(), not load().

Plugin metadata has been updated in load(), with the
side-effect of metadata not beeing available until
plugin has been loaded - and which the new metadata
system tries to prevent in the first place. The
metadata is now updated (and avaiable) as soon as
a valid filename is set.

Change-Id: Ia5aedc67d8115e71c2ecbcbcadf786ba1c2893d8
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Lukas Geyer 2012-08-25 01:06:39 +02:00 committed by Qt by Nokia
parent 32efe589a3
commit f61d02deea
3 changed files with 16 additions and 6 deletions

View File

@ -580,12 +580,19 @@ bool qt_get_metadata(QtPluginQueryVerificationDataFunction pfn, QLibraryPrivate
return true;
}
bool QLibraryPrivate::isPlugin()
{
if (pluginState == MightBeAPlugin)
updatePluginState();
return pluginState == IsAPlugin;
}
void QLibraryPrivate::updatePluginState()
{
errorString.clear();
if (pluginState != MightBeAPlugin)
return pluginState == IsAPlugin;
return;
bool success = false;
@ -599,7 +606,7 @@ bool QLibraryPrivate::isPlugin()
// pretend we didn't see the file
errorString = QLibrary::tr("The shared library was not found.");
pluginState = IsNotAPlugin;
return false;
return;
}
#endif
@ -687,7 +694,8 @@ bool QLibraryPrivate::isPlugin()
else
errorString = QLibrary::tr("The file '%1' is not a valid Qt plugin.").arg(fileName);
}
return false;
pluginState = IsNotAPlugin;
return;
}
pluginState = IsNotAPlugin; // be pessimistic
@ -717,8 +725,6 @@ bool QLibraryPrivate::isPlugin()
} else {
pluginState = IsAPlugin;
}
return pluginState == IsAPlugin;
}
/*!

View File

@ -103,6 +103,7 @@ public:
QString errorString;
QLibrary::LoadHints loadHints;
void updatePluginState();
bool isPlugin();
static inline QJsonDocument fromRawMetaData(const char *raw) {

View File

@ -283,6 +283,9 @@ void QPluginLoader::setFileName(const QString &fileName)
d->loadHints = lh;
if (fn.isEmpty())
d->errorString = QLibrary::tr("The shared library was not found.");
else
d->updatePluginState();
#else
if (qt_debug_component()) {
qWarning("Cannot load %s into a statically linked Qt library.",