src/mainwindow.cpp

changeset 1246
0054d13ed614
parent 1244
68e126e8c629
child 1249
6a8f76f0f4d1
--- a/src/mainwindow.cpp	Thu Feb 15 10:24:39 2018 +0200
+++ b/src/mainwindow.cpp	Thu Feb 15 11:34:04 2018 +0200
@@ -74,10 +74,6 @@
 	connect (m_tabs, SIGNAL (currentChanged(int)), this, SLOT (tabSelected()));
 	connect (m_tabs, SIGNAL (tabCloseRequested (int)), this, SLOT (closeTab (int)));
 	connect(m_documents, SIGNAL(documentClosed(LDDocument*)), this, SLOT(documentClosed(LDDocument*)));
-	connect(
-		ui.objectList->selectionModel(), SIGNAL(selectionChanged()),
-		this, SLOT(selectionChanged())
-	);
 
 	if (m_primitives->activeScanner())
 		connect (m_primitives->activeScanner(), SIGNAL (workDone()), this, SLOT (updatePrimitives()));
@@ -973,6 +969,17 @@
 		updateTitle();
 		print ("Changed document to %1", document->getDisplayName());
 		ui.objectList->setModel(document);
+		QItemSelectionModel* selection = m_selections.value(document);
+
+		if (selection == nullptr)
+		{
+			m_selections[document] = ui.objectList->selectionModel();
+			renderer->setSelectionModel(m_selections[document]);
+		}
+		else
+		{
+			ui.objectList->setSelectionModel(selection);
+		}
 	}
 }
 
@@ -985,9 +992,7 @@
 
 	if (not renderer)
 	{
-		print("MainWindow: Couldn't find a renderer for %1, creating one now", document->getDisplayName());
 		renderer = new Canvas {document, this};
-		print("Created renderer: %1", renderer);
 		m_renderers[document] = renderer;
 		ui.rendererStack->addWidget(renderer);
 		connect(m_messageLog, SIGNAL(changed()), renderer, SLOT(update()));

mercurial