VSTGUI Drag and Drop issue in Studio One 5 on Windows

Hey there,
I’m currently working on a bug where drag and dropping an audio file from the Studio One 5 file browser fails while drops from the OS file explorer work as expected. In other DAW’s dragging from the native browser worked too, it’s really just Studio One that is causing problems.
I already debugged a bit into it but I am not a Windows guy, so any hint is appreciated :slight_smile:

In win32datapackage.cpp:

static FORMATETC formatTEXTDrop		= {CF_UNICODETEXT, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
static FORMATETC formatHDrop		= {CF_HDROP, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
static FORMATETC formatBinaryDrop	= {CF_PRIVATEFIRST, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};

//-----------------------------------------------------------------------------
Win32DataPackage::Win32DataPackage (::IDataObject* platformDataObject)
: platformDataObject (platformDataObject)
, nbItems (0)
, stringsAreFiles (false)
, data (nullptr)
, dataSize (0)
{
	if (!platformDataObject)
		return;

	STGMEDIUM medium = {};
	HRESULT hr = platformDataObject->QueryGetData (&formatTEXTDrop);
	if (hr == S_OK) // text
	{
		hr = platformDataObject->GetData (&formatTEXTDrop, &medium);
		if (hr == S_OK)
		{
			void* data = GlobalLock (medium.hGlobal);
			uint32_t dataSize = static_cast<uint32_t> (GlobalSize (medium.hGlobal));
			if (data && dataSize)
			{
				UTF8StringHelper wideString (static_cast<const WCHAR*> (data), dataSize / 2);
				strings.emplace_back (wideString);
				nbItems = 1;
			}
			GlobalUnlock (medium.hGlobal);
			if (medium.pUnkForRelease)
				medium.pUnkForRelease->Release ();
			else
				GlobalFree (medium.hGlobal);
		}
	}
	else if (hr != S_OK)
	{
		hr = platformDataObject->QueryGetData (&formatHDrop);
		if (hr == S_OK)
		{
			hr = platformDataObject->GetData (&formatHDrop, &medium);
			if (hr == S_OK)
			{
				nbItems = DragQueryFile ((HDROP)medium.hGlobal, 0xFFFFFFFFL, nullptr, 0);
				stringsAreFiles = true;

				TCHAR fileDropped[1024];
				for (uint32_t index = 0; index < nbItems; index++)
				{
					if (DragQueryFile ((HDROP)medium.hGlobal, index, fileDropped, sizeof (fileDropped) / 2)) 
					{
						// resolve link
						checkResolveLink (fileDropped, fileDropped);
						UTF8StringHelper path (fileDropped);
						strings.emplace_back (path);
					}
				}
			}
		}
		else if (platformDataObject->QueryGetData (&formatBinaryDrop) == S_OK)
		{
			if (platformDataObject->GetData (&formatBinaryDrop, &medium) == S_OK)
			{
				const void* blob = GlobalLock (medium.hGlobal);
				dataSize = static_cast<uint32_t> (GlobalSize (medium.hGlobal));
				if (blob && dataSize)
				{
					data = std::malloc (dataSize);
					if (data)
					{
						memcpy (data, blob, dataSize);
						nbItems = 1;
					}
				}
				GlobalUnlock (medium.hGlobal);
				if (medium.pUnkForRelease)
					medium.pUnkForRelease->Release ();
				else
					GlobalFree (medium.hGlobal);
			}
		}
	}
}

When dropping from the Windows Explorer only the check for formatHDrop returns true, which is expected. However, when dropping from the Studio One browser formatHDrop AND formatTEXTDrop are recognized which then defaults to formatTEXTDrop.
If you would flip the order of the if-else blocks loading works as expected from both the Windows Explorer and the Studio One browser.

Is this a VSTGUI bug or rather Studio One returning a faulty message?