src/hierarchyelement.cpp

changeset 970
c8aae45afd85
child 972
a34b73114823
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hierarchyelement.cpp	Mon Aug 31 04:57:16 2015 +0300
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <QMetaObject>
+#include "hierarchyelement.h"
+#include "mainwindow.h"
+
+HierarchyElement::HierarchyElement (QObject* parent) :
+	m_window (nullptr),
+	m_config (nullptr)
+{
+	if (parent)
+	{
+		while (parent->parent() != nullptr)
+			parent = parent->parent();
+	
+		m_window = qobject_cast<MainWindow*> (parent);
+	}
+
+	if (m_window == nullptr)
+	{
+		fprintf (stderr, "FATAL ERROR: Hierarchy element instance %p should be in the hierarchy of a "
+			"MainWindow but isn't.", this);
+		abort();
+	}
+	else
+	{
+		m_config = m_window->configBag();
+	}
+}

mercurial