# HG changeset patch # User truebrain # Date 1211109904 0 # Node ID c1570be72d6c9e78f12061e8d253501ad1e3cb58 # Parent 8d9dbe82af3ca86fa7473a6672fee12cbcb62442 (svn r13157) [NoAI] -Fix: in general it is considered VERY VERY VERY REALLY REALLY bad to delete a class instance from a function inside that class itself. His surrounding is never informed of this 'action', and they all of a sudden have an invalid pointer, causing all kinds of cool and magic effects (read: random crashes all over the place). It might be a REALLY good idea to leave cleaning up of a class instances to the creator of that instance. If you want to cleanup the saveload thread, make a garbage collector. More things use threads (like fibers). Deleting a class like this is bad, worse, worst!!!! !! !!! !!!!! and should be avoided AT ALL COSTS! diff -r 8d9dbe82af3c -r c1570be72d6c src/thread_pthread.cpp --- a/src/thread_pthread.cpp Sun May 11 20:23:26 2008 +0000 +++ b/src/thread_pthread.cpp Sun May 18 11:25:04 2008 +0000 @@ -104,8 +104,6 @@ pthread_join(m_thr, &ret); m_thr = 0; - delete this; - return ret; } @@ -138,21 +136,15 @@ /* The new thread stops here so the calling thread can complete pthread_create() call */ sem_wait(&m_sem_start); - /* Did this thread die naturally/via exit, or did it join? */ - bool exit = false; - /* Call the proc of the creator to continue this thread */ try { m_proc(m_param); } catch (...) { - exit = true; } /* Notify threads waiting for our completion */ sem_post(&m_sem_stop); - if (exit) delete this; - pthread_exit(NULL); } };