[gjs: 2/3] value: Take null boxed pointer into account when calling signal handler
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/3] value: Take null boxed pointer into account when calling signal handler
- Date: Mon, 5 Aug 2019 00:00:46 +0000 (UTC)
commit 718dd8c1c4ae45fdce6da42dd4ae7be42480b0d3
Author: Philip Chimento <philip chimento gmail com>
Date: Thu Aug 1 22:45:33 2019 -0700
value: Take null boxed pointer into account when calling signal handler
This was a regression from commit 91434941, where the error handling
around GError boxed values was improved. Previously null pointers would
sneak through and turn into null JS::Values, but now they were treated
as errors and prevented the signal handler from being called.
The solution is to check for a null pointer coming from C before doing
anything else with it, and return a null JS::Value if so.
Closes: GNOME/gjs#262
gi/value.cpp | 7 +++++++
installed-tests/js/testEverythingBasic.js | 25 +++++++++++++++++++++++++
2 files changed, 32 insertions(+)
---
diff --git a/gi/value.cpp b/gi/value.cpp
index a375c34a..8d567a7f 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -849,6 +849,13 @@ gjs_value_from_g_value_internal(JSContext *context,
else
gboxed = g_value_get_variant(gvalue);
+ if (!gboxed) {
+ gjs_debug_marshal(GJS_DEBUG_GCLOSURE,
+ "Converting null boxed pointer to JS::Value");
+ value_p.setNull();
+ return true;
+ }
+
/* special case GError */
if (g_type_is_a(gtype, G_TYPE_ERROR)) {
obj = ErrorInstance::object_for_c_ptr(context,
diff --git a/installed-tests/js/testEverythingBasic.js b/installed-tests/js/testEverythingBasic.js
index 77bee144..5746c466 100644
--- a/installed-tests/js/testEverythingBasic.js
+++ b/installed-tests/js/testEverythingBasic.js
@@ -719,6 +719,31 @@ describe('Life, the Universe and Everything', function () {
});
});
+ describe('GError signal', function () {
+ let o;
+ beforeEach(function () {
+ o = new Regress.TestObj();
+ });
+
+ it('with GError set', function (done) {
+ o.connect('sig-with-gerror', (obj, e) => {
+ expect(e instanceof Gio.IOErrorEnum).toBeTruthy();
+ expect(e.domain).toEqual(Gio.io_error_quark());
+ expect(e.code).toEqual(Gio.IOErrorEnum.FAILED);
+ done();
+ });
+ o.emit_sig_with_error();
+ }).pend('https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/169');
+
+ it('with no GError set', function (done) {
+ o.connect('sig-with-gerror', (obj, e) => {
+ expect(e).toBeNull();
+ done();
+ });
+ o.emit_sig_with_null_error();
+ }).pend('https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/169');
+ });
+
// Calling matches() on an unpaired error used to JSUnit.assert:
// https://bugzilla.gnome.org/show_bug.cgi?id=689482
it('bug 689482', function () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]