From 03b1612ce2aac360397c699d6c9fd0486df3481c Mon Sep 17 00:00:00 2001
From: Shon Ferguson <shonferg@users.sourceforge.net>
Date: Fri, 10 Feb 2006 05:39:32 +0000
Subject: [PATCH] Gave preference to Node blocks in GetParent function.

---
 NIF_Blocks.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/NIF_Blocks.cpp b/NIF_Blocks.cpp
index bd8d26f9..74428b76 100644
--- a/NIF_Blocks.cpp
+++ b/NIF_Blocks.cpp
@@ -166,10 +166,17 @@ vector<attr_ref> ABlock::GetAttrs() const {
 }
 
 blk_ref ABlock::GetParent() const {
-	if (_parents.size() > 0 )
+	if (_parents.size() > 0 ) {
+		//Give preferential treatment to the first node parent
+		for ( uint i = 0; i < _parents.size(); ++i ) {
+			if ( _parents[i]->QueryInterface( ID_NODE ) ) {
+				return _parents[i];
+			}
+		}
 		return blk_ref(_parents[0]);
-	else
+	} else {
 		return blk_ref(-1);
+	}
 }
 
 list<blk_ref> ABlock::GetParents() const {
-- 
GitLab