소스 검색

Fix issue with material shader initializing twice
Fix issue with drag and drop manager not properly disconnecting its event before shutdown

Marko Pintera 11 년 전
부모
커밋
53d89dfdff

+ 1 - 1
BansheeCore/Include/BsMaterial.h

@@ -635,7 +635,7 @@ namespace BansheeEngine
 	private:
 		friend class MaterialManager;
 
-		Material() { }
+		Material();
 		Material(const HShader& shader);
 
 		/**

+ 19 - 10
BansheeCore/Source/BsMaterial.cpp

@@ -455,6 +455,7 @@ namespace BansheeEngine
 	void TMaterial<false>::setShader(ShaderType shader)
 	{
 		mShader = shader;
+		mBestTechnique = nullptr;
 		_markResourcesDirty();
 
 		if (mShader)
@@ -469,7 +470,6 @@ namespace BansheeEngine
 		}
 
 		initBestTechnique();
-
 		_markCoreDirty();
 	}
 
@@ -899,6 +899,9 @@ namespace BansheeEngine
 		return materialPtr;
 	}
 
+	Material::Material()
+	{ }
+
 	Material::Material(const HShader& shader)
 	{
 		mShader = shader;
@@ -1005,23 +1008,29 @@ namespace BansheeEngine
 
 	void Material::notifyResourceLoaded(const HResource& resource)
 	{
-		initBestTechnique();
-
-		markCoreDirty();
+		if (mBestTechnique == nullptr)
+		{
+			initBestTechnique();
+			markCoreDirty();
+		}
 	}
 
 	void Material::notifyResourceDestroyed(const HResource& resource)
 	{
-		initBestTechnique();
-
-		markCoreDirty();
+		if (mBestTechnique == nullptr)
+		{
+			initBestTechnique();
+			markCoreDirty();
+		}
 	}
 
 	void Material::notifyResourceChanged(const HResource& resource)
 	{
-		initBestTechnique();
-
-		markCoreDirty();
+		if (mBestTechnique == nullptr)
+		{
+			initBestTechnique();
+			markCoreDirty();
+		}
 	}
 
 	HMaterial Material::create()

+ 2 - 0
BansheeEngine/Include/BsDragAndDropManager.h

@@ -31,6 +31,7 @@ namespace BansheeEngine
 	{
 	public:
 		DragAndDropManager();
+		~DragAndDropManager();
 
 		/**
 		 * @brief	Starts a drag operation of the specified type. This means GUI elements will start receiving
@@ -122,6 +123,7 @@ namespace BansheeEngine
 		Vector<std::function<void(bool)>> mDropCallbacks;
 		bool mIsDragInProgress;
 		bool mNeedsValidDropTarget;
+		HEvent mMouseCaptureChangedConn;
 
 		std::atomic<bool> mCaptureChanged;
 		std::atomic<int> mCaptureActive;

+ 6 - 1
BansheeEngine/Source/BsDragAndDropManager.cpp

@@ -9,10 +9,15 @@ namespace BansheeEngine
 	DragAndDropManager::DragAndDropManager()
 		:mIsDragInProgress(false), mDragTypeId(0), mData(nullptr), mCaptureChanged(false), mCaptureActive(0), mNeedsValidDropTarget(false)
 	{
-		Platform::onMouseCaptureChanged.connect(std::bind(&DragAndDropManager::mouseCaptureChanged, this));
+		mMouseCaptureChangedConn = Platform::onMouseCaptureChanged.connect(std::bind(&DragAndDropManager::mouseCaptureChanged, this));
 		Input::instance().onPointerReleased.connect(std::bind(&DragAndDropManager::cursorReleased, this, _1));
 	}
 
+	DragAndDropManager::~DragAndDropManager()
+	{
+		mMouseCaptureChangedConn.disconnect();
+	}
+
 	void DragAndDropManager::addDropCallback(std::function<void(bool)> dropCallback)
 	{
 		mDropCallbacks.push_back(dropCallback);