Menu

Crash bug related to TGLContext

Help
Edwin
2016-04-13
2016-04-15
  • Edwin

    Edwin - 2016-04-13

    About four years ago, I found a bug that crashed GLScene. Since the forum
    that I posted that on appears to be gone and I can't submit tickets, I'll
    mention it again.

    When using multiple contexts, you can get into a situation where vMTC in
    XOpenGL.pas refers to a TGLMultitextureCoordinator that does not exist
    anymore. From memory, this happened after I created a temporary memory
    context for rendering to an image. If the last used context is deleted,
    then xgl() function will happily return the vMTC still pointing to the
    deleted context.

    To fix this, I created this function in XOpenGL.pas:

    procedure removeXgl(mtc: TAbstractMultitextureCoordinator);
    begin
    if vMTC = mtc then
    vMTC := nil;
    end;

    And call it from TGLContext.Destroy.

    I'm not sure if this is the best solution, but it gets rid of the problem.
    I hope this fix (or something with similar effect) can be included in the
    main tree.

    Thanks,
    Edwin

     
    • Edwin

      Edwin - 2016-04-14

      In reply to the comment to this post:

      I just added "removeXgl(FXGL);" before "FXGL.Free();" in
      TGLContext.Destroy. It just clears the reference before the context is
      destroyed, so not much else to explain.

      Edwin

      On 13 April 2016 at 15:02, Edwin V e.velds@gmail.com wrote:

      About four years ago, I found a bug that crashed GLScene. Since the forum
      that I posted that on appears to be gone and I can't submit tickets, I'll
      mention it again.

      When using multiple contexts, you can get into a situation where vMTC in
      XOpenGL.pas refers to a TGLMultitextureCoordinator that does not exist
      anymore. From memory, this happened after I created a temporary memory
      context for rendering to an image. If the last used context is deleted,
      then xgl() function will happily return the vMTC still pointing to the
      deleted context.

      To fix this, I created this function in XOpenGL.pas:

      procedure removeXgl(mtc: TAbstractMultitextureCoordinator);
      begin
      if vMTC = mtc then
      vMTC := nil;
      end;

      And call it from TGLContext.Destroy.

      I'm not sure if this is the best solution, but it gets rid of the problem.
      I hope this fix (or something with similar effect) can be included in the
      main tree.

      Thanks,
      Edwin

       
      • Pavel Vassiliev

        Pavel Vassiliev - 2016-04-14

        Edwin,

        I just added "removeXgl(FXGL);" before "FXGL.Free();" in
        TGLContext.Destroy. It just clears the reference before the context is
        destroyed, so not much else to explain.<<<

        In this case you will have a circular calls of units XOpenGL and GLContext, that's not good decision.
        PW

         
      • Edwin

        Edwin - 2016-04-15

        I'm personally not bothered by circular unit references. In fact, I'm more
        annoyed that Delphi refuses to do so at interface level. Anyway, it's
        either that or change the entire xgl() system to prevent the invalid
        pointer.

        P.S. Why is it not possible to reply to comments directly?

         
  • Pavel Vassiliev

    Pavel Vassiliev - 2016-04-13

    Hi Edwin,
    Ok, I've included RemoveXgl in XOpenGL.pas but give, please, more details on where and how you are calling it from TGLContext.Destroy for other users.
    PW

     
  • LefjuCabro

    LefjuCabro - 2017-04-04

    Hi,

    I have nearly same issue (access violation) with v1.4 & v1.5 under Delphi Berlin.
    The issue is in XOpenGL/function xgl(): vMTC (TGLMultitextureCoordinator) is unavailable.
    It happens when I want to reopen a form (containing 4 GLSceneWiever) that had been open then close.

    Lefju

     
  • LefjuCabro

    LefjuCabro - 2017-04-05
     

    Last edit: LefjuCabro 2017-04-05
  • LefjuCabro

    LefjuCabro - 2017-04-07

    To solve my crash I enable SoftwareMode in SceneViewer.Buffer.ContextOptions
    If it can help someone...
    Lefju

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.