MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / dependsSort

Method dependsSort

src/framework/lifecycle/private/pluginmanager_p.cpp:474–540  ·  view source on GitHub ↗

! * \brief PluginManagerPrivate::dependsSort 插件依赖排序算法 * \param srcQueue 传入需要排序的插件源队列 * \return 返回排序后的Queue */

Source from the content-addressed store, hash-verified

472 * \return 返回排序后的Queue
473 */
474PluginManagerPrivate::PluginMetaQueue PluginManagerPrivate::dependsSort(
475 const PluginManagerPrivate::PluginMetaQueue &srcQueue)
476{
477 dpfCheckTimeBegin();
478
479 QMutexLocker lock(&GlobalPrivate::mutex);
480
481 PluginMetaQueue result;
482
483 if (srcQueue.isEmpty())
484 return result;
485
486 PluginMetaQueue temp = srcQueue;
487 auto itera = temp.begin();
488 while (itera != temp.end()) {
489 if ((*itera)->depends().isEmpty()) {
490 result.append(*itera);
491 itera = temp.erase(itera);
492 continue;
493 }
494 itera ++;
495 }
496
497 auto dependsNoContains = [=](const PluginMetaQueue &src, const PluginMetaObjectPointer &elem) {
498 QList<QString> result;
499 QList<QString> srcPluginNames;
500 for (auto val : src) {
501 srcPluginNames << val->name();
502 }
503
504 for (auto depend : elem->depends()) {
505 if (!srcPluginNames.contains(depend.name())) {
506 result << depend.name();
507 }
508 }
509 return result;
510 };
511
512 while (!temp.isEmpty()) {
513 auto itera = temp.begin();
514 while (itera != temp.end()) {
515 auto srcNoContains = dependsNoContains(srcQueue, *itera);
516 auto dstNoContains = dependsNoContains(result, *itera);
517 if (!srcNoContains.isEmpty()) {
518 qCritical() << "Error, invalid plugin depends: " << srcNoContains
519 << " from plugin: " << (*itera)->name();
520 for (auto noContainsVal : srcNoContains) {
521 // Delete not existen plugin depend from plugin-name
522 dstNoContains.removeOne(noContainsVal);
523 }
524 // claer not existen plugin depend from plugin-name
525 srcNoContains.clear();
526 }
527
528 if (dstNoContains.isEmpty()) {
529 result.append(*itera);
530 itera = temp.erase(itera);
531 continue;

Callers

nothing calls this directly

Calls 9

dependsMethod · 0.80
eraseMethod · 0.80
isEmptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
appendMethod · 0.45
nameMethod · 0.45
containsMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected