Skip to content

Enhance OpenGlControlBase.cs #17011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Conversation

heku
Copy link
Contributor

@heku heku commented Sep 13, 2024

What does the pull request do?

  1. Dispose IGlContext correctly
  2. Refactor OpenGL initialization check

What is the current behavior?

In the following case, the ctx is not disposed.

if(_resources == null)
{
    var contextFactory = AvaloniaLocator.Current.GetRequiredService<IPlatformGraphicsOpenGlContextFactory>();
    ctx = contextFactory.CreateContext(null);
    if (ctx.TryGetFeature<IGlContextExternalObjectsFeature>(out var externalObjects))
         // If line below returns null, ctx is not disposed.
        _resources = OpenGlControlBaseResources.TryCreate(ctx, surface, interop, externalObjects);  
    else
        ctx.Dispose();
}

if(_resources == null)
{
    Logger.TryGet(LogEventLevel.Error, "OpenGL")?.Log("OpenGlControlBase",
        "Unable to initialize OpenGL: current platform does not support multithreaded context sharing and shared memory");
    return false;
}

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0051868-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

1. Dispose IGlContext correctly
2. Refactor OpenGL initialization check
@heku heku force-pushed the OpenGLControlBase branch from c5170ab to 18bdb79 Compare September 20, 2024 23:16
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0051989-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 requested a review from kekekeks September 22, 2024 02:45
@maxkatz6 maxkatz6 merged commit f472205 into AvaloniaUI:master Nov 14, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants