Fix clearing the list of wizard factories

Clearing the list of wizard factories did not result in updating the
available JSON wizards. The JSON wizard paths were scanned only once at
startup. Instead partially revert back to before
1cf6b031cf and let the JSON "factory
creator" parse the directories and return a list of wizard factories.

Change-Id: Ifc253479973be801c5323588800bb264610187b6
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Eike Ziller
2023-11-16 14:53:44 +01:00
parent 4362318c14
commit b60fd77fc1
6 changed files with 50 additions and 33 deletions

View File

@@ -186,33 +186,35 @@ QList<IWizardFactory*> IWizardFactory::allWizardFactories()
QHash<Id, IWizardFactory *> sanityCheck;
for (const FactoryCreator &fc : std::as_const(s_factoryCreators)) {
IWizardFactory *newFactory = fc();
// skip factories referencing wizard page generators provided by plugins not loaded
if (!newFactory)
continue;
IWizardFactory *existingFactory = sanityCheck.value(newFactory->id());
for (IWizardFactory *newFactory : fc()) {
if (!newFactory) // should not happen, but maybe something went wrong
continue;
IWizardFactory *existingFactory = sanityCheck.value(newFactory->id());
QTC_ASSERT(existingFactory != newFactory, continue);
if (existingFactory) {
qWarning("%s", qPrintable(Tr::tr("Factory with id=\"%1\" already registered. Deleting.")
.arg(existingFactory->id().toString())));
delete newFactory;
continue;
}
QTC_ASSERT(!newFactory->m_action, continue);
newFactory->m_action = new QAction(newFactory->displayName(), newFactory);
ActionManager::registerAction(newFactory->m_action, actionId(newFactory));
connect(newFactory->m_action, &QAction::triggered, newFactory, [newFactory] {
if (!ICore::isNewItemDialogRunning()) {
FilePath path = newFactory->runPath({});
newFactory->runWizard(path, ICore::dialogParent(), Id(), QVariantMap());
QTC_ASSERT(existingFactory != newFactory, continue);
if (existingFactory) {
qWarning("%s",
qPrintable(
Tr::tr("Factory with id=\"%1\" already registered. Deleting.")
.arg(existingFactory->id().toString())));
delete newFactory;
continue;
}
});
sanityCheck.insert(newFactory->id(), newFactory);
s_allFactories << newFactory;
QTC_ASSERT(!newFactory->m_action, continue);
newFactory->m_action = new QAction(newFactory->displayName(), newFactory);
ActionManager::registerAction(newFactory->m_action, actionId(newFactory));
connect(newFactory->m_action, &QAction::triggered, newFactory, [newFactory] {
if (!ICore::isNewItemDialogRunning()) {
FilePath path = newFactory->runPath({});
newFactory->runWizard(path, ICore::dialogParent(), Id(), QVariantMap());
}
});
sanityCheck.insert(newFactory->id(), newFactory);
s_allFactories << newFactory;
}
}
}
@@ -322,6 +324,11 @@ void IWizardFactory::registerFactoryCreator(const IWizardFactory::FactoryCreator
s_factoryCreators << creator;
}
void IWizardFactory::registerFactoryCreator(const std::function<IWizardFactory *()> &creator)
{
s_factoryCreators << [creator] { return QList<IWizardFactory *>({creator()}); };
}
QSet<Id> IWizardFactory::allAvailablePlatforms()
{
QSet<Id> platforms;