Request PluginListComponent::scanFor


Can you make PluginListComponent::scanFor static, so i can use it outside the PluginListComponent?
I could also copy the function, but i don’t like the duplication of code…

… and please increase the time in the dispatchLoop (20ms) , currently i get heavy redraw artefacts, while the app is not responding

[code]for (;:wink:
aw.setMessage (TRANS(“Testing:\n\n”)
+ scanner.getNextPluginFileThatWillBeScanned());

    MessageManager::getInstance()->runDispatchLoopUntil (300);  // instead of 20



300 seems a bit much - how about 100 instead?

But how could I make the method static? It uses properties of the PluginListComponent…


yes 100 should be ok too!
…with parameter passing?, but a better solution is to create a seperate PluginListHelpers class/namespace ( for separating GUI an App-Logic)

Here it is:

class PluginListHelpers 
	static void scanFor(AudioPluginFormat* format, KnownPluginList& list,PropertiesFile* propertiesToUse, File deadMansPedalFile)
		if (format == nullptr)

		FileSearchPath path (format->getDefaultLocationsToSearch());

		if (propertiesToUse != nullptr)
			path = propertiesToUse->getValue ("lastPluginScanPath_" + format->getName(), path.toString());

			AlertWindow aw (TRANS("Select folders to scan..."), String::empty, AlertWindow::NoIcon);
			FileSearchPathListComponent pathList;
			pathList.setSize (500, 300);
			pathList.setPath (path);

			aw.addCustomComponent (&pathList);
			aw.addButton (TRANS("Scan"), 1, KeyPress::returnKey);
			aw.addButton (TRANS("Cancel"), 0, KeyPress::escapeKey);

			if (aw.runModalLoop() == 0)

			path = pathList.getPath();

		if (propertiesToUse != nullptr)
			propertiesToUse->setValue ("lastPluginScanPath_" + format->getName(), path.toString());

		double progress = 0.0;

		AlertWindow aw (TRANS("Scanning for plugins..."),
			TRANS("Searching for all possible plugin files..."), AlertWindow::NoIcon);

		aw.addButton (TRANS("Cancel"), 0, KeyPress::escapeKey);
		aw.addProgressBarComponent (progress);


		MessageManager::getInstance()->runDispatchLoopUntil (100);

		PluginDirectoryScanner scanner (list, *format, path, true, deadMansPedalFile);

		for (;;)
			aw.setMessage (TRANS("Testing:\n\n")
				+ scanner.getNextPluginFileThatWillBeScanned());

			MessageManager::getInstance()->runDispatchLoopUntil (20);

			if (! scanner.scanNextFile (true))

			if (! aw.isCurrentlyModal())

			progress = scanner.getProgress();

		if (scanner.getFailedFiles().size() > 0)
			StringArray shortNames;

			for (int i = 0; i < scanner.getFailedFiles().size(); ++i)
				shortNames.add (File (scanner.getFailedFiles()[i]).getFileName());

			AlertWindow::showMessageBox (AlertWindow::InfoIcon,
				TRANS("Scan complete"),
				TRANS("Note that the following files appeared to be plugin files, but failed to load correctly:\n\n")
				+ shortNames.joinIntoString (", "));
				jassertfalse; // this method needs refactoring to work without modal loops..


and then in juce_PluginListComponent.cpp just

void PluginListComponent::timerCallback()
	PluginListHelpers::scanFor (AudioPluginFormatManager::getInstance()->getFormat (typeToScan),list,propertiesToUse,deadMansPedalFile);


Hmm, doesn’t feel like the right place for it… Maybe it’d be more appropriate as a method of the AudioPluginFormat class?


Yes, that would be also fine :slight_smile:


i’m seeing you working on these classes now, so again my request is, that it would be nice to use “scanFor” independently from the GUI-Classes (separating GUI from functionality)


bump, sorry.

At least can you make scanFor public, so i can hold an instance of PluginListComponent in the background, and can trigger the plugin-scanning.
(so i can benefit from the latest plugin-scanning code, without duplicating the code it in my own classes…) Please.


Ok, will do that.


thanks, could you also add this method to PluginListComponent… (so i can check how long the component needs to be alive, after calling scanFor)

bool isCurrentlyScanning() { return currentScanner!=nullptr; }


Sure, will do.