Skip to content
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

Enhance OpenGlControlBase.cs #17011

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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;
}

1. Dispose IGlContext correctly
2. Refactor OpenGL initialization check
@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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants