vstgui icon indicating copy to clipboard operation
vstgui copied to clipboard

Windows clipboard drops Binary data package

Open sophiapoirier opened this issue 2 years ago • 1 comments

On Windows, if I supply a call to VSTGUI::getPlatformFactory().setClipboard with a VSTGUI::IDataPackage that kBinary data type, then a subsequent call to VSTGUI::getPlatformFactory().getClipboard() returns an object whose getCount() returns 0.

sophiapoirier avatar Jul 18 '21 20:07 sophiapoirier

To provide some code that I am working with that demonstrates the problem:

class SettingsDataPackage final : public VSTGUI::IDataPackage
{
public:
	SettingsDataPackage(std::byte const* inSettingsData, VstInt32 inSettingsDataSize)
	:	mData(inSettingsData, std::next(inSettingsData, inSettingsDataSize))
	{
	}

	uint32_t getCount() const override
	{
		return mData.empty() ? 0 : 1;
	}

	uint32_t getDataSize(uint32_t inIndex) const override
	{
		if (inIndex >= getCount())
		{
			return 0;
		}
		return mData.size();
	}

	Type getDataType(uint32_t inIndex) const override
	{
		if (inIndex >= getCount())
		{
			return kError;
		}
		return kBinary;
	}

	uint32_t getData(uint32_t inIndex, void const*& outBuffer, Type& outType) const override
	{
		outBuffer = (inIndex < getCount()) ? mData.data() : nullptr;
		outType = getDataType(inIndex);
		return getDataSize(inIndex);
	}

private:
	std::vector<std::byte> const mData;
};

and then:

auto const dataPackage = VSTGUI::makeOwned<SettingsDataPackage>(data, dataSize);
auto const success = VSTGUI::getPlatformFactory().setClipboard(dataPackage);

(which returns as successful)

and later:

auto const clipboardData = VSTGUI::getPlatformFactory().getClipboard();

where clipboardData->getCount() then returns 0.

sophiapoirier avatar Jul 21 '21 03:07 sophiapoirier