Forráskód Böngészése

Bugfix: Fix a crash when selecting multiple objects in the Hierarchy window

BearishSun 6 éve
szülő
commit
22b09b8f50

+ 7 - 2
Source/EditorCore/GUI/BsGUISceneTreeView.cpp

@@ -405,6 +405,11 @@ namespace bs
 	}
 
 	void GUISceneTreeView::setSelection(const Vector<HSceneObject>& objects)
+	{
+		setSelection(objects, false);
+	}
+
+	void GUISceneTreeView::setSelection(const Vector<HSceneObject>& objects, bool triggerEvents)
 	{
 		unselectAll(false);
 
@@ -424,7 +429,7 @@ namespace bs
 			if (iterFind != objects.end())
 			{
 				expandToElement(currentElem);
-				selectElement(currentElem);
+				selectElement(currentElem, triggerEvents);
 			}
 
 			for (auto& child : currentElem->mChildren)
@@ -667,7 +672,7 @@ namespace bs
 
 		TreeElement* newTreeElement = findTreeElement(newSO);
 		expandToElement(newTreeElement);
-		setSelection({ newSO });
+		setSelection({ newSO }, true);
 		renameSelected();
 
 		onModified();

+ 6 - 0
Source/EditorCore/GUI/BsGUISceneTreeView.h

@@ -202,6 +202,12 @@ namespace bs
 		/**	Removes all elements from the list used for copy/cut operations. */
 		void clearCopyList();
 
+		/**	
+		 * Changes the active selection to the provided SceneObject%s and optionally triggers the necessary event 
+		 * callbacks. 
+		 */
+		void setSelection(const Vector<HSceneObject>& objects, bool triggerEvents);
+
 		/** Iterates over the tree element hierarchy, starting with the provided element and calls @p predicate. */
 		template<class T>
 		void recurse(SceneTreeElement* element, T predicate) const

+ 6 - 4
Source/EditorCore/GUI/BsGUITreeView.cpp

@@ -498,7 +498,7 @@ namespace bs
 		return mIsElementSelected && mSelectedElements.size() > 0;
 	}
 
-	void GUITreeView::selectElement(TreeElement* element)
+	void GUITreeView::selectElement(TreeElement* element, bool triggerEvents)
 	{
 		clearPing();
 
@@ -516,11 +516,12 @@ namespace bs
 			mSelectedElements.push_back(SelectedElement(element, background));
 			mIsElementSelected = true;
 
-			selectionChanged();
+			if(triggerEvents)
+				selectionChanged();
 		}
 	}
 
-	void GUITreeView::unselectElement(TreeElement* element)
+	void GUITreeView::unselectElement(TreeElement* element, bool triggerEvents)
 	{
 		clearPing();
 
@@ -535,7 +536,8 @@ namespace bs
 			mSelectedElements.erase(iterFind);
 			_markLayoutAsDirty();
 
-			selectionChanged();
+			if(triggerEvents)
+				selectionChanged();
 		}
 
 		mIsElementSelected = mSelectedElements.size() > 0;

+ 2 - 2
Source/EditorCore/GUI/BsGUITreeView.h

@@ -213,10 +213,10 @@ namespace bs
 		bool isSelectionActive() const;
 
 		/**	Expands the selection to the provided TreeElement. Doesn't clear previous selection. */
-		void selectElement(TreeElement* element);
+		void selectElement(TreeElement* element, bool triggerEvents = true);
 
 		/**	Unselects the provided TreeElement. */
-		void unselectElement(TreeElement* element);
+		void unselectElement(TreeElement* element, bool triggerEvents = true);
 
 		/**
 		 * Unselects all selected TreeElement%s.