openglcontrol: fixed double free, issue #35335, from Denis Golovan

git-svn-id: trunk@60866 -
This commit is contained in:
mattias 2019-04-07 17:43:03 +00:00
parent a6e96bfe61
commit 11e60c45bc
2 changed files with 7 additions and 3 deletions

View File

@ -49,7 +49,7 @@ function gdk_gl_context_share_new(visual: PGdkVisual; sharelist: PGdkGLContext;
function gdk_gl_context_attrlist_share_new(attrlist: Plongint; function gdk_gl_context_attrlist_share_new(attrlist: Plongint;
sharelist: PGdkGLContext; direct: TGLBool): PGdkGLContext; sharelist: PGdkGLContext; direct: TGLBool): PGdkGLContext;
function gdk_gl_context_ref(context: PGdkGLContext): PGdkGLContext; function gdk_gl_context_ref(context: PGdkGLContext): PGdkGLContext;
procedure gdk_gl_context_unref(context:PGdkGLContext); function gdk_gl_context_unref(context:PGdkGLContext): PGdkGLContext;
function gdk_gl_make_current(drawable: PGdkDrawable; function gdk_gl_make_current(drawable: PGdkDrawable;
context: PGdkGLContext): boolean; context: PGdkGLContext): boolean;
procedure gdk_gl_swap_buffers(drawable: PGdkDrawable); procedure gdk_gl_swap_buffers(drawable: PGdkDrawable);
@ -279,7 +279,8 @@ begin
g_return_if_fail (GTK_IS_GL_AREA(obj),''); g_return_if_fail (GTK_IS_GL_AREA(obj),'');
gl_area := GTK_GL_AREA(obj); gl_area := GTK_GL_AREA(obj);
gdk_gl_context_unref(gl_area^.glcontext); if gl_area^.glcontext <> nil then // avoid double-free
gl_area^.glcontext := gdk_gl_context_unref(gl_area^.glcontext);
if Assigned(GTK_OBJECT_CLASS(parent_class)^.destroy) then if Assigned(GTK_OBJECT_CLASS(parent_class)^.destroy) then
GTK_OBJECT_CLASS(parent_class)^.destroy(obj); GTK_OBJECT_CLASS(parent_class)^.destroy(obj);
@ -430,10 +431,11 @@ begin
Result:=context; Result:=context;
end; end;
procedure gdk_gl_context_unref(context: PGdkGLContext); function gdk_gl_context_unref(context: PGdkGLContext):PGdkGLContext;
var var
PrivateContext: PGdkGLContextPrivate; PrivateContext: PGdkGLContextPrivate;
begin begin
Result:=context;
g_return_if_fail(context<>nil,''); g_return_if_fail(context<>nil,'');
PrivateContext:=PGdkGLContextPrivate(context); PrivateContext:=PGdkGLContextPrivate(context);
@ -447,6 +449,7 @@ begin
PrivateContext^.glxcontext:=nil; PrivateContext^.glxcontext:=nil;
g_free(PrivateContext); g_free(PrivateContext);
//DebugLn(['gdk_gl_context_unref END']); //DebugLn(['gdk_gl_context_unref END']);
Result:=nil;
end; end;
end; end;

View File

@ -734,6 +734,7 @@ end;
class function TWSOpenGLControl.GetDoubleBuffered(const AWinControl: TWinControl): Boolean; class function TWSOpenGLControl.GetDoubleBuffered(const AWinControl: TWinControl): Boolean;
begin begin
Result := False; Result := False;
if AWinControl=nil then ;
end; end;
initialization initialization