Unexpected plugin behaviour on Windows


#1

I’m not sure where to start with this one. Some of my users have reported some strange graphics problems on Windows (perhaps related to this). I have a host that is largely based on the Audio Plugin host demo. Users click a node and it brings up the plugin editor window. To access the underlying editor I use the following code:

CabbagePluginEditor* CabbageMainComponent::getCabbagePluginEditor()
{

        const AudioProcessorGraph::NodeID nodeId(fileTabs[currentFileIndex]->uniqueFileId);
		if (auto f = audioGraph->graph.getNodeForId(nodeId))
			if (auto* w = audioGraph->getOrCreateWindowFor(f, PluginWindow::Type::normal))
			{
				const auto processor = w->node->getProcessor();
				if (processor != nullptr)
				{
					//processor->getActiveEditor() return nullptr the second time this method is called;
					if (CabbagePluginEditor* editor = dynamic_cast<CabbagePluginEditor*> (processor->getActiveEditor()))
						return editor;
				}
			}

	return nullptr;
}

This works fine the first time I try to access the current editor, but at some point during subsequent calls getAciveEditor() suddenly returns a nullptr. The plugin window is still showing the editor. getOrCreateWindowFor() is getting the window, not creating it so the node is valid. The corresponding processor object is also valid. But for some reason the editor is not. My editor destructor is not getting called at any point either. The problem only shows up on the most recent versions of Windows and doesn’t appear on any other platform. I’m using Windows 10 SDK 10.0.17763.0.

I don’t suppose anyone might have some ideas on what might be causing this, or how best to debug? I’m completely stumped.

[edit] I found a workaround for this by keeping a pointer to the last created editor, but it just feels wrong. I’m still all ears for possible reasons this happens.