gtk4: Reset app context and display if GL context creation fails

No need to keep them around and that way we either have all 3 values set
or none of them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1032>
This commit is contained in:
Sebastian Dröge 2022-12-29 10:56:56 +02:00
parent 4ee70913bd
commit 9ec06199b1

View file

@ -678,6 +678,8 @@ impl PaintableSink {
Ok(_) => gst::info!(CAT, imp: self, "Successfully activated GL Context."),
Err(_) => {
gst::error!(CAT, imp: self, "Failed to activate GL context",);
*app_ctx_guard = None;
*display_guard = None;
return false;
}
};
@ -696,12 +698,16 @@ impl PaintableSink {
"Failed to deactivate the context after failing fill info",
);
}
*app_ctx_guard = None;
*display_guard = None;
return false;
}
if app_ctx.activate(false).is_err() {
gst::error!(CAT, imp: self, "Failed to deactivate GL context",);
*app_ctx_guard = None;
*display_guard = None;
return false;
}
@ -720,6 +726,8 @@ impl PaintableSink {
}
Err(err) => {
gst::error!(CAT, imp: self, "Could not create GL context: {err}");
*app_ctx_guard = None;
*display_guard = None;
false
}
}