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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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:
Edwin,
In this case you will have a circular calls of units XOpenGL and GLContext, that's not good decision.
PW
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?
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
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
Last edit: LefjuCabro 2017-04-05
To solve my crash I enable
SoftwareMode
inSceneViewer.Buffer.ContextOptions
If it can help someone...
Lefju