Browse Source
Properly rethrow RegisterTick errors instead of returning generic E_FAIL (#14938)
pull/15109/head
Max Katz
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
11 additions and
5 deletions
-
native/Avalonia.Native/src/OSX/PlatformRenderTimer.mm
-
src/Avalonia.Native/AvaloniaNativeRenderTimer.cs
-
src/Avalonia.Native/avn.idl
|
|
@ -8,7 +8,7 @@ private: |
|
|
|
|
|
|
|
|
public: |
|
|
public: |
|
|
FORWARD_IUNKNOWN() |
|
|
FORWARD_IUNKNOWN() |
|
|
virtual HRESULT RegisterTick ( |
|
|
virtual int RegisterTick ( |
|
|
IAvnActionCallback* callback) override |
|
|
IAvnActionCallback* callback) override |
|
|
{ |
|
|
{ |
|
|
START_COM_CALL; |
|
|
START_COM_CALL; |
|
|
@ -24,13 +24,13 @@ public: |
|
|
auto result = CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink); |
|
|
auto result = CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink); |
|
|
if (result != 0) |
|
|
if (result != 0) |
|
|
{ |
|
|
{ |
|
|
return E_FAIL; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
result = CVDisplayLinkSetOutputCallback(_displayLink, OnTick, this); |
|
|
result = CVDisplayLinkSetOutputCallback(_displayLink, OnTick, this); |
|
|
if (result != 0) |
|
|
if (result != 0) |
|
|
{ |
|
|
{ |
|
|
return E_FAIL; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return S_OK; |
|
|
return S_OK; |
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Diagnostics; |
|
|
using System.Diagnostics; |
|
|
|
|
|
using System.Runtime.InteropServices; |
|
|
using Avalonia.Native.Interop; |
|
|
using Avalonia.Native.Interop; |
|
|
using Avalonia.Rendering; |
|
|
using Avalonia.Rendering; |
|
|
#nullable enable |
|
|
#nullable enable |
|
|
@ -29,7 +30,12 @@ internal sealed class AvaloniaNativeRenderTimer : NativeCallbackBase, IRenderTim |
|
|
if (!registered) |
|
|
if (!registered) |
|
|
{ |
|
|
{ |
|
|
registered = true; |
|
|
registered = true; |
|
|
_platformRenderTimer.RegisterTick(this); |
|
|
var registrationResult = _platformRenderTimer.RegisterTick(this); |
|
|
|
|
|
if (registrationResult != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new InvalidOperationException( |
|
|
|
|
|
$"Avalonia.Native was not able to start the RenderTimer. Native error code is: {registrationResult}"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (_subscriberCount++ == 0) |
|
|
if (_subscriberCount++ == 0) |
|
|
|
|
|
@ -1202,7 +1202,7 @@ interface IAvnPlatformBehaviorInhibition : IUnknown |
|
|
[uuid(22edf20d-5803-2d3f-9247-b4842e5e9322)] |
|
|
[uuid(22edf20d-5803-2d3f-9247-b4842e5e9322)] |
|
|
interface IAvnPlatformRenderTimer : IUnknown |
|
|
interface IAvnPlatformRenderTimer : IUnknown |
|
|
{ |
|
|
{ |
|
|
HRESULT RegisterTick(IAvnActionCallback* callback); |
|
|
int RegisterTick(IAvnActionCallback* callback); |
|
|
void Start(); |
|
|
void Start(); |
|
|
void Stop(); |
|
|
void Stop(); |
|
|
bool RunsInBackground(); |
|
|
bool RunsInBackground(); |
|
|
|