src/hierarchyelement.cpp

Mon, 31 Aug 2015 20:50:12 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 31 Aug 2015 20:50:12 +0300
changeset 971
c00f9665a9f8
parent 970
c8aae45afd85
child 972
a34b73114823
permissions
-rw-r--r--

Now compiles and links but crashes shortly after startup.

#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