Ivan Safrin 13 лет назад
Родитель
Сommit
dda069be43

+ 2 - 0
Core/Contents/Include/PolyCore.h

@@ -312,6 +312,8 @@ namespace Polycode {
 		
 		CoreMutex *getEventMutex();
 		CoreMutex *eventMutex;
+		
+		void removeThread(Threaded *thread);
 				
 	protected:	
 		

+ 1 - 1
Core/Contents/Include/PolyThreaded.h

@@ -38,7 +38,7 @@ namespace Polycode{
 	class _PolyExport Threaded : public EventDispatcher {
 	public:
 		Threaded();
-		virtual ~Threaded(){}
+		virtual ~Threaded();
 		
 		/**
 		* Sets the thread running flag to false.

+ 15 - 1
Core/Contents/Source/PolyCore.cpp

@@ -139,7 +139,21 @@ namespace Polycode {
 	CoreMutex *Core::getEventMutex() {
 		return eventMutex;
 	}
-			
+	
+	void Core::removeThread(Threaded *thread) {
+		if(threadedEventMutex){ 
+			lockMutex(threadedEventMutex);
+	
+			for(int i=0; i < threads.size(); i++) {
+				if(threads[i] == thread) {
+					threads.erase(threads.begin() + i);
+					return;
+				}
+			}
+			unlockMutex(threadedEventMutex);			
+		}
+	}
+							
 	void Core::updateCore() {
 		frames++;
 		frameTicks = getTicks();

+ 1 - 1
Core/Contents/Source/PolyScreenSprite.cpp

@@ -77,7 +77,7 @@ void ScreenSprite::playAnimation(const String& name, int startFrame, bool once)
 	paused = false;
 	for(int i=0; i < animations.size(); i++) {
 		if(animations[i]->name == name) {
-			if(currentAnimation == animations[i])
+			if(currentAnimation == animations[i] && !playingOnce)
 				return;
 			currentFrame = 0;			
 			currentAnimation = animations[i];

+ 4 - 0
Core/Contents/Source/PolyThreaded.cpp

@@ -9,6 +9,10 @@ Threaded::Threaded() : EventDispatcher() {
 	scheduledForRemoval = false;
 }
 
+Threaded::~Threaded() {
+	core->removeThread(this);
+}
+
 void Threaded::killThread() {
 	threadRunning = false;
 }

+ 1 - 1
Modules/Contents/Curl/PolycodeDownloader.h

@@ -8,7 +8,7 @@ using namespace Polycode;
 class PolycodeDownloader : public Threaded {
 	public:
 		PolycodeDownloader(String url);
-		~PolycodeDownloader();		
+		virtual ~PolycodeDownloader();		
 		
 		void runThread();