[vala] codegen: Fix uncaught errors in constructors and destructors



commit 63172079a648519997c859c96d7279c31cec2b80
Author: Jürg Billeter <j bitron ch>
Date:   Fri Oct 22 15:40:23 2010 +0200

    codegen: Fix uncaught errors in constructors and destructors

 codegen/valaccodebasemodule.vala |    4 ++--
 codegen/valagerrormodule.vala    |    4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 9a53fc2..e37416f 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -130,7 +130,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		}
 	}
 
-	bool is_in_constructor () {
+	public bool is_in_constructor () {
 		var sym = current_symbol;
 		while (sym != null) {
 			if (sym is Constructor) {
@@ -141,7 +141,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		return false;
 	}
 
-	bool is_in_destructor () {
+	public bool is_in_destructor () {
 		var sym = current_symbol;
 		while (sym != null) {
 			if (sym is Destructor) {
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index b7b4436..3ccc68f 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -135,7 +135,9 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 		ccode.add_expression (ccritical);
 		ccode.add_expression (cclear);
 
-		if (current_method is CreationMethod) {
+		if (is_in_constructor () || is_in_destructor ()) {
+			// just print critical, do not return prematurely
+		} else if (current_method is CreationMethod) {
 			if (current_method.parent_symbol is Struct) {
 				ccode.add_return ();
 			} else {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]