! \internal */
| 942 | \internal |
| 943 | */ |
| 944 | bool PluginSpecPrivate::loadLibrary() |
| 945 | { |
| 946 | if (hasError) |
| 947 | return false; |
| 948 | if (state != PluginSpec::Resolved) { |
| 949 | if (state == PluginSpec::Loaded) |
| 950 | return true; |
| 951 | errorString = QCoreApplication::translate("PluginSpec", "Loading the library failed because state != Resolved"); |
| 952 | hasError = true; |
| 953 | return false; |
| 954 | } |
| 955 | #ifdef QT_NO_DEBUG |
| 956 | |
| 957 | #ifdef Q_OS_WIN |
| 958 | QString libName = QString::fromLatin1("%1/%2.dll").arg(location).arg(name); |
| 959 | #elif defined(Q_OS_MAC) |
| 960 | QString libName = QString::fromLatin1("%1/lib%2.dylib").arg(location).arg(name); |
| 961 | #else |
| 962 | QString libName = QString::fromLatin1("%1/lib%2.so").arg(location).arg(name); |
| 963 | #endif |
| 964 | |
| 965 | #else //Q_NO_DEBUG |
| 966 | |
| 967 | #ifdef Q_OS_WIN |
| 968 | QString libName = QString::fromLatin1("%1/%2d.dll").arg(location).arg(name); |
| 969 | #elif defined(Q_OS_MAC) |
| 970 | QString libName = QString::fromLatin1("%1/lib%2.dylib").arg(location).arg(name); |
| 971 | #else |
| 972 | QString libName = QString::fromLatin1("%1/lib%2.so").arg(location).arg(name); |
| 973 | #endif |
| 974 | |
| 975 | #endif |
| 976 | |
| 977 | PluginLoader loader(libName); |
| 978 | if (!loader.load()) { |
| 979 | hasError = true; |
| 980 | errorString = QDir::toNativeSeparators(libName) |
| 981 | + QString::fromLatin1(": ") + loader.errorString(); |
| 982 | return false; |
| 983 | } |
| 984 | IPlugin *pluginObject = qobject_cast<IPlugin*>(loader.instance()); |
| 985 | if (!pluginObject) { |
| 986 | hasError = true; |
| 987 | errorString = QCoreApplication::translate("PluginSpec", "Plugin is not valid (does not derive from IPlugin)"); |
| 988 | loader.unload(); |
| 989 | return false; |
| 990 | } |
| 991 | state = PluginSpec::Loaded; |
| 992 | plugin = pluginObject; |
| 993 | plugin->d->pluginSpec = q; |
| 994 | return true; |
| 995 | } |
| 996 | |
| 997 | /*! |
| 998 | \internal |
no test coverage detected