Browse Source

Inheriting from virtual class no longer causes the engine to crash, it prints an error instead.

Co-authored-by: Hein-Pieter van Braam <[email protected]>
QbieShay 6 years ago
parent
commit
8f22c2684f
1 changed files with 2 additions and 1 deletions
  1. 2 1
      modules/gdscript/gdscript.cpp

+ 2 - 1
modules/gdscript/gdscript.cpp

@@ -152,12 +152,13 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro
 	}
 	}
 
 
 	ERR_FAIL_COND_V(_baseptr->native.is_null(), Variant());
 	ERR_FAIL_COND_V(_baseptr->native.is_null(), Variant());
-
 	if (_baseptr->native.ptr()) {
 	if (_baseptr->native.ptr()) {
 		owner = _baseptr->native->instance();
 		owner = _baseptr->native->instance();
 	} else {
 	} else {
 		owner = memnew(Reference); //by default, no base means use reference
 		owner = memnew(Reference); //by default, no base means use reference
 	}
 	}
+	ERR_EXPLAIN("Can't inherit from a virtual class");
+	ERR_FAIL_COND_V(!owner, Variant());
 
 
 	Reference *r = Object::cast_to<Reference>(owner);
 	Reference *r = Object::cast_to<Reference>(owner);
 	if (r) {
 	if (r) {