src/hierarchyelement.cpp

changeset 1160
2cf16ba952bf
parent 1097
9a9e6ce0c5dc
child 1192
317f4ce38f3f
child 1251
e75cc5bff076
--- a/src/hierarchyelement.cpp	Thu Feb 23 20:18:39 2017 +0200
+++ b/src/hierarchyelement.cpp	Thu Feb 23 20:21:40 2017 +0200
@@ -35,11 +35,10 @@
 
 	if (m_window == nullptr)
 	{
-		// Drat! It doesn't seem to have the MainWindow as a parent! We'll need to force it to be in one.
-		// This shouldn't have any side effects but also shouldn't happen regardless.
-		m_window = g_win;
-		print("Hierarchy element instance %1 should have a MainWindow parent, but it is %2 (%3).\n", this,
-		      parent, parent ? parent->metaObject()->className() : "nullptr");
+		// The MainWindow relation should have been found.
+		QString error = format("Hierarchy element instance %1 should have a MainWindow parent, but it is %2 (%3).\n",
+		                       this, parent, parent ? parent->metaObject()->className() : "nullptr");
+		throw std::runtime_error {error.toUtf8().constData()};
 	}
 
 	m_documents = m_window->documents();
@@ -87,4 +86,4 @@
 {
 	QString caLicenseText = "!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt";
 	return m_config->useCaLicense() ? caLicenseText : "";
-}
\ No newline at end of file
+}

mercurial