mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
D2D: Avoid crashing when attempting to create a vblank dispatcher on a headless system
This commit is contained in:
parent
9be03bc99e
commit
a37b35ad15
1 changed files with 17 additions and 10 deletions
|
|
@ -102,6 +102,9 @@ public:
|
||||||
|
|
||||||
static HMONITOR getMonitorFromOutput (ComSmartPtr<IDXGIOutput> output)
|
static HMONITOR getMonitorFromOutput (ComSmartPtr<IDXGIOutput> output)
|
||||||
{
|
{
|
||||||
|
if (output == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
DXGI_OUTPUT_DESC desc = {};
|
DXGI_OUTPUT_DESC desc = {};
|
||||||
return (FAILED (output->GetDesc (&desc)) || ! desc.AttachedToDesktop)
|
return (FAILED (output->GetDesc (&desc)) || ! desc.AttachedToDesktop)
|
||||||
? nullptr
|
? nullptr
|
||||||
|
|
@ -214,18 +217,22 @@ public:
|
||||||
|
|
||||||
for (const auto& adapter : directX->adapters.getAdapterArray())
|
for (const auto& adapter : directX->adapters.getAdapterArray())
|
||||||
{
|
{
|
||||||
UINT i = 0;
|
for (UINT i = 0;; ++i)
|
||||||
|
{
|
||||||
ComSmartPtr<IDXGIOutput> output;
|
ComSmartPtr<IDXGIOutput> output;
|
||||||
|
const auto result = adapter->dxgiAdapter->EnumOutputs (i, output.resetAndGetPointerAddress());
|
||||||
|
|
||||||
|
if (result == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (result == DXGI_ERROR_NOT_FOUND)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (VBlankThread::getMonitorFromOutput (output) != monitor)
|
||||||
|
continue;
|
||||||
|
|
||||||
while (adapter->dxgiAdapter->EnumOutputs (i, output.resetAndGetPointerAddress()) != DXGI_ERROR_NOT_FOUND)
|
|
||||||
{
|
|
||||||
if (VBlankThread::getMonitorFromOutput (output) == monitor)
|
|
||||||
{
|
|
||||||
threads.emplace_back (std::make_unique<VBlankThread> (output, monitor, listener));
|
threads.emplace_back (std::make_unique<VBlankThread> (output, monitor, listener));
|
||||||
return;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue