Skip to content

Commit

Permalink
fix: initialize the effect before getting uniforms
Browse files Browse the repository at this point in the history
The `get_uniform_location` function was called before the GLSL effect
pipeline was initialized, which caused a GNOME Shell crash. This commit
adds the superclass constructor call before uniform fetching, ensuring
that context is initialized.

Fixes: yilozt#156
  • Loading branch information
flexagoon committed May 2, 2024
1 parent 9c6005c commit d0ab083
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/effect/rounded_corners_effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ export const RoundedCornersEffect = GObject.registerClass (
*/
static uniforms: Uniforms = new Uniforms ()

/**
* Collect location of uniform variants, only used when added shader
* snippet to effect.
*/
private _init_uniforms () {
constructor () {
Effect.uniforms = {
bounds: 0,
clip_radius: 0,
Expand All @@ -56,6 +52,9 @@ export const RoundedCornersEffect = GObject.registerClass (
border_width: 0,
border_color: 0,
}

super ()

Object.keys (Effect.uniforms).forEach ((k) => {
if (!Effect.uniforms) return
Effect.uniforms[k as keyof Uniforms] = this.get_uniform_location (k)
Expand All @@ -65,7 +64,6 @@ export const RoundedCornersEffect = GObject.registerClass (
vfunc_build_pipeline (): void {
const type = Shell.SnippetHook.FRAGMENT
this.add_glsl_snippet (type, declarations, code, false)
this._init_uniforms ()
}

vfunc_paint_target (node: Clutter.PaintNode, ctx: Clutter.PaintContext) {
Expand Down

0 comments on commit d0ab083

Please sign in to comment.