Browse Source

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

Marko Pintera 11 years ago
parent
commit
53d89dfdff

+ 1 - 1
BansheeCore/Include/BsMaterial.h

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

+ 19 - 10
BansheeCore/Source/BsMaterial.cpp

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

+ 2 - 0
BansheeEngine/Include/BsDragAndDropManager.h

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

+ 6 - 1
BansheeEngine/Source/BsDragAndDropManager.cpp

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