当前位置: 首页>>代码示例>>C++>>正文


C++ QPluginLoader::errorString方法代码示例

本文整理汇总了C++中QPluginLoader::errorString方法的典型用法代码示例。如果您正苦于以下问题:C++ QPluginLoader::errorString方法的具体用法?C++ QPluginLoader::errorString怎么用?C++ QPluginLoader::errorString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPluginLoader的用法示例。


在下文中一共展示了QPluginLoader::errorString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: make_pair

ISCORE_LIB_BASE_EXPORT
std::pair<QString, iscore::Plugin_QtInterface*> PluginLoader::loadPlugin(
        const QString &fileName,
        const std::vector<iscore::Plugin_QtInterface*>& availablePlugins)
{
#if !defined(ISCORE_STATIC_QT)
    auto blacklist = pluginsBlacklist();
    QPluginLoader loader {fileName};

    if(QObject* plugin = loader.instance())
    {
        auto iscore_plugin = dynamic_cast<iscore::Plugin_QtInterface*>(plugin);
        if(!iscore_plugin)
        {
            qDebug() << "Warning: plugin"
                     << plugin->metaObject()->className()
                     << "is not an i-score plug-in.";
            return {};
        }

        // Check if the plugin is not already loaded
        auto plug_it =
                find_if(availablePlugins,
                        [&] (iscore::Plugin_QtInterface* obj)
        { return obj->key() == iscore_plugin->key(); });

        if(plug_it != availablePlugins.end())
        {
            qDebug() << "Warning: plugin"
                     << plugin->metaObject()->className()
                     << "was already loaded. Not reloading.";

            return std::make_pair(fileName, nullptr);
        }

        // Check if it is blacklisted
        if(blacklist.contains(fileName))
        {
            plugin->deleteLater();
            return std::make_pair(fileName, nullptr);
        }

        // We can load the plug-in
        return std::make_pair(fileName, iscore_plugin);
    }
    else
    {
        QString s = loader.errorString();
        if(!s.contains("Plugin verification data mismatch") && !s.contains("is not a Qt plugin"))
            qDebug() << "Error while loading" << fileName << ": " << loader.errorString();
        return {};
    }
#endif

    return {};
}
开发者ID:Sciss,项目名称:i-score,代码行数:56,代码来源:PluginManager.cpp

示例2: run

void PluginLoaderThread::run()
{
    if (m_queue.empty() || m_targetThread == 0) {
        qCritical() << "Invalid plugin loading parameters";
        return;
    }

    while (!m_queue.isEmpty()) {
        QPluginLoader * loader = new QPluginLoader ();
        loader->setFileName (m_queue.takeFirst());
        loader->setLoadHints (QLibrary::ExportExternalSymbolsHint);

        if (loader->load()) {
            QMutexLocker locker(&m_mutex);
            if (!m_abort) {
                loader->moveToThread(m_targetThread);
                //loader->setParent(parent());
            }
            else {
                qDebug() << "Plugin loading aborted, exiting loader thread";
                delete loader;
                loader = 0;
                break;
            }
        }
        else {
            qCritical() << "Failed to load plugin:" << loader->errorString();
            delete loader;
            loader = 0;
        }

        Q_EMIT(pluginLoaded(loader, m_queue.isEmpty()));
    }
}
开发者ID:nemomobile-graveyard,项目名称:libshare-ui,代码行数:34,代码来源:pluginloaderthread.cpp

示例3: loadMySqlDriver

void loadMySqlDriver()
{
    QPluginLoader loader;
    loader.setFileName("/opt/qtsdk-2010.04/qt/plugins/sqldrivers/libqsqlmysql.so");
    qDebug()<<loader.load();
    qDebug()<<loader.errorString();
}
开发者ID:xian0gang,项目名称:test,代码行数:7,代码来源:main.cpp

示例4: path

static QList<VirtualKeyboardFactory *> getVKBFactories()
{
    QList<VirtualKeyboardFactory *> list;
    QString path("/usr/lib/luna");
    qDebug() << "\033[1;33;45m" << Q_FUNC_INFO << "Searching for VKB plugins in" << path << "\033[0m";

    QDir plugindir = QDir(path);
    QStringList files = plugindir.entryList(QDir::Files);
    qDebug() << "\033[1;33;45m" << Q_FUNC_INFO << "Found" << files.count() << "files" << "\033[0m";

    QPluginLoader loader;
    QStringList::const_iterator it = files.constBegin();

    while (it != files.constEnd()) {
        qDebug() << "\033[1;33;40m" << Q_FUNC_INFO << "Checking" << (*it) << "\033[0m";
        loader.setFileName(plugindir.absoluteFilePath(*it));

        VirtualKeyboardFactory *factory =
            qobject_cast<VirtualKeyboardFactory *>(loader.instance());

        if (factory) {
            qDebug() << "\033[1;32;40m" << Q_FUNC_INFO << "Loaded plugin"
                     << (*it) << "successfully" << "\033[0m";
            list.append(factory);
        } else {
            qWarning() << "\033[1;31;40m" << Q_FUNC_INFO << "Failed to load"
                       << (*it) << "\n" << loader.errorString() << "\033[0m";

        }

        ++it;
    }

    return list;
}
开发者ID:KyleMaas,项目名称:luna-sysmgr,代码行数:35,代码来源:IMEManager.cpp

示例5: loadPlugin

void PluginManager::loadPlugin(QString const & path)
{
    qDebug() << "Load plugin: " << path;

    Q_ASSERT(mPluginLoaders.find(path) == mPluginLoaders.end());

    QPluginLoader * loader = new QPluginLoader(path, this);

    if (!loader->load())
    {
        qDebug() << loader->errorString();
        qDebug() << QString("Can't load plugin '%1'").arg(path);
    }

    // process instances
    PluginInterface *plugInterface = qobject_cast<PluginInterface*>(loader->instance());
    if (plugInterface != 0)
    {
        mPluginLoaders[path] = loader;
        processLoadPlugin(plugInterface);
    }else
    {
        delete loader;
        qDebug() << QString("There are no plugin interface in '%1'").arg(path);
    }

}
开发者ID:AlexKlybik,项目名称:kbe,代码行数:27,代码来源:pluginmanager.cpp

示例6: loadPlugins

void AbstractPluginLoader::loadPlugins(const QRegExp& fileRx, QVector<QString>* errors)
{
  Q_D(AbstractPluginLoader);
  const QDir pluginsFolder(this->loadingFolder());
  QStringList entries(pluginsFolder.entryList(QDir::Files));
  foreach (const QString& entry, entries) {
    if (fileRx.indexIn(entry) != -1 && ::isLibrary(entry)) {
      // Try to load the plugin
#ifdef DEBUG_ABSTRACT_PLUGIN_LOADER
      qDebug() << "try to load" << entry;
#endif // DEBUG_ABSTRACT_PLUGIN_LOADER
      QPluginLoader* pluginLoader = new QPluginLoader(pluginsFolder.absoluteFilePath(entry));
      QObject* plugin = pluginLoader->instance();
      // Is the plugin compatible ?
      if (this->isPluginCompatible(plugin)) {
        d->m_plugins.append(plugin);
        d->m_pluginLoaders.append(pluginLoader);
        d->m_pluginFilenames.insert(plugin, entry);
      }
      else {
#ifdef DEBUG_ABSTRACT_PLUGIN_LOADER
        qDebug() << "  not added";
#endif // DEBUG_ABSTRACT_PLUGIN_LOADER
        if (errors != NULL)
          //: %1 holds the path to a plugin (DLL)
          //: %2 holds an error description
          errors->append(QObject::tr("Failed to load plugin (maybe wrong interface) %1 : %2")
                         .arg(pluginLoader->fileName())
                         .arg(pluginLoader->errorString()));
        pluginLoader->unload();
        delete pluginLoader;
      } // end if (this->isPluginCompatible(plugin))
    } // end if (fileRx.indexIn(entry) != -1)
  } // end foreach ()
}
开发者ID:neoplacer,项目名称:fougtools,代码行数:35,代码来源:abstract_plugin_loader.cpp

示例7: loadPlugin

void suiPluginManager::loadPlugin(const QString &fileName)
{
    qDebug() << "Load plugin: " << fileName;

    if (mPluginLoaders.find(fileName) != mPluginLoaders.end())
        SuiExcept(SuiExceptionDuplicateItem,
                  QString("Plugin '%1' already loaded").arg(fileName),
                  "void suiPluginManager::loadPlugin(const QString &fileName)");

    QPluginLoader *loader = new QPluginLoader(fileName, this);

    if (!loader->load())
    {
        qDebug() << loader->errorString();
        SuiExcept(SuiExceptionInternalError,
                  QString("Can't load plugin '%1'").arg(fileName),
                  "void suiPluginManager::loadPlugin(const QString &fileName)");
    }

    // process instances
    UiPluginInterface *plugInterface = qobject_cast<UiPluginInterface*>(loader->instance());
    if (plugInterface != 0)
    {
        mPluginLoaders[fileName] = loader;
        processLoadPlugin(plugInterface);
    }else
    {
        delete loader;
        SuiExcept(SuiExceptionInternalError,
                  QString("There are no plugin interface in '%1'").arg(fileName),
                  "void suiPluginManager::loadPlugin(const QString &fileName)");
    }
}
开发者ID:asvitenkov,项目名称:sui,代码行数:33,代码来源:suipluginmanager.cpp

示例8: loadPlugins

void GLWidget::loadPlugins(const QStringList& list) {
    QStringList::ConstIterator it = list.constBegin();
    while(it != list.constEnd()) 
    {
        QString name = *it;
        QPluginLoader *loader = new QPluginLoader(name);
        if (! loader->load()) {
        	  qDebug() << "Could not load plugin " << name << "\n";
                qDebug() << loader->errorString() << "\n";

	        }
        if (loader->isLoaded()) 
        {
            qDebug() << "Loaded plugin: " << loader->fileName(); // << 	endl;
            QObject *plugin = loader->instance();
            if (plugin) 
            {
                plugins.push_back(loader); 
                BasicPlugin *plugin = qobject_cast<BasicPlugin *>(loader->instance());
                // initialize plugin
                if (plugin)
                {
                    plugin->setWidget(this);
                    plugin->setArgs(mainArgs);
                    plugin->onPluginLoad();
                    if (plugin->drawScene()) // overrides drawScene?
                        drawPlugin = plugin;
                }
            }
        }
        else 
        {
            qDebug() << "Load error: " << name << endl;
	        delete loader;
        }
        
        ++it;
    }

    // make sure all plugins know about the latest plugin that overrides drawScene
    for (unsigned int i=0; i<plugins.size(); ++i)
    {
        BasicPlugin *plugin = qobject_cast<BasicPlugin *>(plugins[i]->instance());
        if (plugin)
            plugin->setDrawPlugin(drawPlugin);
        else
        {
            qDebug() << "Error: the plugin must implement the BasicPlugin interface" << endl <<
            " Example: " << endl << 
            "   Q_INTERFACES(BasicPlugin)" << endl;
        }
    }

    resetCamera();
}
开发者ID:EikaNN,项目名称:FIB-G,代码行数:55,代码来源:glwidget.cpp

示例9: qCWarning

QObject *PluginLoader::createForName(const QString &name)
{
    if (!mPluginInfos.contains(name)) {
        qCWarning(AKONADICORE_LOG) << "plugin name \"" << name << "\" is unknown to the plugin loader." << endl;
        return 0;
    }

    PluginMetaData &info = mPluginInfos[name];

    //First try to load it staticly
    foreach (QObject *plugin, QPluginLoader::staticInstances()) {
        if (QLatin1String(plugin->metaObject()->className()) == info.className) {
            info.loaded = true;
            return plugin;
            break;
        }
    }

    if (!info.loaded) {
        QPluginLoader *loader = new QPluginLoader(info.library);
        if (loader->fileName().isEmpty()) {
            qCWarning(AKONADICORE_LOG) << loader->errorString();
            delete loader;
            return 0;
        }

        mPluginLoaders.insert(name, loader);
        info.loaded = true;
    }

    QPluginLoader *loader = mPluginLoaders.value(name);
    Q_ASSERT(loader);

    QObject *object = loader->instance();
    if (!object) {
        qCWarning(AKONADICORE_LOG) << "unable to load plugin" << info.library << "for plugin name" << name << ".";
        qCWarning(AKONADICORE_LOG) << "Error was:\"" << loader->errorString() << "\".";
        return 0;
    }

    return object;
}
开发者ID:KDE,项目名称:akonadi,代码行数:42,代码来源:pluginloader.cpp

示例10: loadPlugins

void PluginManagerPrivate::loadPlugins()
{
    if (m_pluginsLoaded)
    {
        return;
    }

    QTime t;
    t.start();
    mDebug() << "Starting to load Plugins.";

    QStringList pluginFileNameList = MarbleDirs::pluginEntryList( "", QDir::Files );

    MarbleDirs::debug();

    Q_ASSERT( m_renderPluginTemplates.isEmpty() );
    Q_ASSERT( m_positionProviderPluginTemplates.isEmpty() );
    Q_ASSERT( m_searchRunnerPlugins.isEmpty() );
    Q_ASSERT( m_reverseGeocodingRunnerPlugins.isEmpty() );
    Q_ASSERT( m_routingRunnerPlugins.isEmpty() );
    Q_ASSERT( m_parsingRunnerPlugins.isEmpty() );

    foreach( const QString &fileName, pluginFileNameList ) {
        // mDebug() << fileName << " - " << MarbleDirs::pluginPath( fileName );
        QString const path = MarbleDirs::pluginPath( fileName );
        QPluginLoader* loader = new QPluginLoader( path );

        QObject * obj = loader->instance();

        if ( obj ) {
            bool isPlugin = appendPlugin<RenderPlugin, RenderPluginInterface>
                       ( obj, loader, m_renderPluginTemplates );
            isPlugin = isPlugin || appendPlugin<PositionProviderPlugin, PositionProviderPluginInterface>
                       ( obj, loader, m_positionProviderPluginTemplates );
            isPlugin = isPlugin || appendPlugin<SearchRunnerPlugin, SearchRunnerPlugin>
                       ( obj, loader, m_searchRunnerPlugins ); // intentionally T==U
            isPlugin = isPlugin || appendPlugin<ReverseGeocodingRunnerPlugin, ReverseGeocodingRunnerPlugin>
                       ( obj, loader, m_reverseGeocodingRunnerPlugins ); // intentionally T==U
            isPlugin = isPlugin || appendPlugin<RoutingRunnerPlugin, RoutingRunnerPlugin>
                       ( obj, loader, m_routingRunnerPlugins ); // intentionally T==U
            isPlugin = isPlugin || appendPlugin<ParseRunnerPlugin, ParseRunnerPlugin>
                       ( obj, loader, m_parsingRunnerPlugins ); // intentionally T==U
            if ( !isPlugin ) {
                qWarning() << "Ignoring the following plugin since it couldn't be loaded:" << path;
                mDebug() << "Plugin failure:" << path << "is a plugin, but it does not implement the "
                        << "right interfaces or it was compiled against an old version of Marble. Ignoring it.";
                delete loader;
            }
        } else {
            qWarning() << "Ignoring to load the following file since it doesn't look like a valid Marble plugin:" << path << endl
                       << "Reason:" << loader->errorString();
            delete loader;
        }
    }
开发者ID:AndreiDuma,项目名称:marble,代码行数:54,代码来源:PluginManager.cpp

示例11: loadPlugins

void PluginManagerPrivate::loadPlugins()
{
    if (m_pluginsLoaded)
    {
        return;
    }

    QTime t;
    t.start();
    mDebug() << "Starting to load Plugins.";

    QStringList pluginFileNameList = MarbleDirs::pluginEntryList( "", QDir::Files );

    MarbleDirs::debug();

    qDeleteAll( m_renderPluginTemplates );
    m_renderPluginTemplates.clear();

    qDeleteAll( m_networkPluginTemplates );
    m_networkPluginTemplates.clear();

    qDeleteAll( m_positionProviderPluginTemplates );
    m_positionProviderPluginTemplates.clear();

    // No need to delete runner plugins

    foreach( const QString &fileName, pluginFileNameList ) {
        // mDebug() << fileName << " - " << MarbleDirs::pluginPath( fileName );
        QString const path = MarbleDirs::pluginPath( fileName );
        QPluginLoader* loader = new QPluginLoader( path );

        QObject * obj = loader->instance();

        if ( obj ) {
            bool isPlugin = appendPlugin<RenderPlugin, RenderPluginInterface>
                       ( obj, loader, m_renderPluginTemplates );
            isPlugin = isPlugin || appendPlugin<NetworkPlugin, NetworkPluginInterface>
                       ( obj, loader, m_networkPluginTemplates );
            isPlugin = isPlugin || appendPlugin<PositionProviderPlugin, PositionProviderPluginInterface>
                       ( obj, loader, m_positionProviderPluginTemplates );
            isPlugin = isPlugin || appendPlugin<RunnerPlugin, RunnerPlugin>
                       ( obj, loader, m_runnerPlugins ); // intentionally T==U
            if ( !isPlugin ) {
                mDebug() << "Plugin failure:" << fileName << "is a plugin, but it does not implement the "
                        << "right interfaces or it was compiled against an old version of Marble. Ignoring it.";
                delete loader;
            }
        } else {
            mDebug() << "Plugin failure:" << fileName << "is not a valid Marble Plugin:"
                     << loader->errorString();
        }
    }
开发者ID:snowy97,项目名称:marble,代码行数:52,代码来源:PluginManager.cpp

示例12: log

 // looking for dynamic plugins
 foreach(const QFileInfo & fileName, files)
 {
     emit log((int)LogDebug, MODULENAME, QString("Loading plugin: %1").arg(fileName.fileName()), "");
     QPluginLoader loader;
     loader.setLoadHints(QLibrary::ResolveAllSymbolsHint|QLibrary::ExportExternalSymbolsHint);
     loader.setFileName( fileName.absoluteFilePath());
     if (!loader.load())
     {
         qCritical() << loader.errorString();
         continue;
     }
     QObject *plugin = loader.instance();
     if (plugin && qobject_cast<PropertyInterface*>(plugin))
         m_plugins.push_back(qobject_cast<PropertyInterface*>(plugin));
     else
         emit log((int)LogWarning, MODULENAME, QString("It\'s not a PropertyEditor plugin: %1").arg(fileName.fileName()), "");
 }
开发者ID:navrocky,项目名称:CuteReport,代码行数:18,代码来源:propertyeditorcore.cpp

示例13: load

void QAudioPluginLoader::load()
{
    if (!m_plugins.isEmpty())
        return;

    QStringList plugins = pluginList();
    for (int i=0; i < plugins.count(); i++) {
        QPluginLoader* loader = new QPluginLoader(plugins.at(i));
        QObject *o = loader->instance();
        if (o != 0 && o->qt_metacast(m_iid) != 0)
            m_plugins.append(loader);
        else {
            qWarning() << "QAudioPluginLoader: Failed to load plugin: "
                << plugins.at(i) << loader->errorString();
        }
    }
}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:17,代码来源:qaudiopluginloader.cpp

示例14: unloadPlugin

bool EditorManager::unloadPlugin(QString const &pluginName)
{
	QPluginLoader *loader = mLoaders[mPluginFileName[pluginName]];
	if (loader != NULL) {
		mLoaders.remove(mPluginFileName[pluginName]);
		mPluginIface.remove(pluginName);
		mPluginFileName.remove(pluginName);
		mPluginsLoaded.removeAll(pluginName);
		if (!loader->unload()) {
			QMessageBox::warning(NULL, tr("error"), tr("Plugin unloading failed: ") + loader->errorString());
			delete loader;
			return false;
		}
		delete loader;
		return true;
	}
	return false;
}
开发者ID:Esenin,项目名称:qreal,代码行数:18,代码来源:editorManager.cpp

示例15: unloadPlugin

QString PluginManagerImplementation::unloadPlugin(QString const &pluginName)
{
	QPluginLoader *loader = mLoaders[pluginName];

	if (loader) {
		mLoaders.remove(pluginName);

		if (!loader->unload()) {
			QString const error = loader->errorString();
			delete loader;
			return error;
		}

		delete loader;
		return QString();
	}

	return QString("Plugin was not found");
}
开发者ID:Anna-,项目名称:qreal,代码行数:19,代码来源:pluginManagerImplementation.cpp


注:本文中的QPluginLoader::errorString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。