[gjs: 1/3] object: Throw when trying to instantiate an abstract type
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/3] object: Throw when trying to instantiate an abstract type
- Date: Sat, 27 Apr 2019 03:56:23 +0000 (UTC)
commit 92e7dc274ade246bd9b632e37defe71cd15926c4
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Apr 26 21:58:21 2019 +0000
object: Throw when trying to instantiate an abstract type
Trying to instantiate an abstract type is a fatal error on the
gobject-level. While this is undoubtably an error, we can handle
the case more gracefully by detecting the condition and throwing
an exception instead.
https://gitlab.gnome.org/GNOME/gjs/merge_requests/290
gi/object.cpp | 6 ++++++
1 file changed, 6 insertions(+)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 1a9cf50c..ad9ee655 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1464,6 +1464,12 @@ ObjectInstance::init_impl(JSContext *context,
if (!m_proto->props_to_g_parameters(context, args, &names, &values))
return false;
+ if (G_TYPE_IS_ABSTRACT(gtype())) {
+ gjs_throw(context,
+ "Cannot instantiate abstract type %s", g_type_name(gtype()));
+ return false;
+ }
+
/* Mark this object in the construction stack, it
will be popped in gjs_object_custom_init() later
down.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]