Index: /orxonox/branches/physics/src/subprojects/particles/framework.cc
===================================================================
--- /orxonox/branches/physics/src/subprojects/particles/framework.cc	(revision 4330)
+++ /orxonox/branches/physics/src/subprojects/particles/framework.cc	(revision 4331)
@@ -29,10 +29,8 @@
 #include "camera.h"
 
-#include <pthread.h>
 
 int verbose;
 
-pthread_mutex_t mutex;
-
+int quitGui(GtkWidget* widget, void* data);
 
 
@@ -41,15 +39,7 @@
   // Creating a Test Particle System
   ParticleSystem* system = new ParticleSystem(100000, PARTICLE_SPRITE);
-  system->setLifeSpan(5);
-  system->setConserve(.999);
-  system->setRadius(4, 3, 1, 2);
-  system->setColor(.5,0,0,.5, 1,1,0,1, 0,0,0,0);
 
   // Creating a Test Particle Emitter
-  ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0), M_PI_4, 20, .1);
-  emitter->setType(EMITTER_DOT  );
-  emitter->setSize(0);
-  emitter->setRelCoor(Vector(0,0,0));
-  
+  ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0));
   // Add the Flow from the Emitter into the System
   ParticleEngine::getInstance()->addConnection(emitter, system);
@@ -59,9 +49,11 @@
 {
   Framework* framework = Framework::getInstance();
-  while(true)
+  while(!framework->isFinished)
     {
+      while(gtk_events_pending()) 
+	gtk_main_iteration();
+
       // keyhandler returns false if sdl gets quit by some event
-      if (!framework->keyHandler())
-	pthread_exit(NULL);
+      framework->keyHandler();
 
       // tick the scene
@@ -69,10 +61,8 @@
 
       // Draw the scene
-      pthread_mutex_lock (&mutex); 
       framework->draw(dt);
-      pthread_mutex_unlock (&mutex);
+
     }
 }
-
 
 bool Framework::draw(float dt)
@@ -163,6 +153,7 @@
 	switch (event.key.keysym.sym)
 	  {
-	  case SDLK_x:
-	    
+	  case SDLK_q:
+	  case SDLK_ESCAPE:
+	    quitGui(NULL, NULL);
 	    break;
 	  case SDLK_c:
@@ -187,5 +178,5 @@
       case SDL_QUIT:
 	// then we're done and we'll end this program
-	return false;
+	quitGui(NULL, NULL);
 	break;
       default:
@@ -204,4 +195,9 @@
 }
 
+void Framework::quit(void)
+{
+  this->isFinished = true;
+}
+
 Framework* Framework::singletonRef = NULL;
 
@@ -215,4 +211,6 @@
 Framework::Framework()
 {
+  this->isFinished = false;
+
   this->lastFrame = 0;
   // Create a new OpenGL window with the title "Cone3D Basecode" at
@@ -368,4 +366,5 @@
   gtk_main_quit();
   while(gtk_events_pending()) gtk_main_iteration();
+  Framework::getInstance()->quit();
 #endif /* HAVE_GTK2 */
 }
@@ -492,30 +491,12 @@
 {
   verbose = 3;
-  pthread_t guiThread;
-  pthread_t openglThread;
-  pthread_attr_t attr;
-  int status;
   
-  pthread_mutex_init(&mutex, NULL);
-  
-  /* Create threads to perform the dotproduct  */
-  pthread_attr_init(&attr);
-  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
-
-
-
   Framework* framework = Framework::getInstance();
 
   framework->initGui((void*)argv);
-  pthread_create(&guiThread, &attr, Framework::mainloopGui ,(void*) argv);
-  //  framework->initGui(argv);
-
-  pthread_create(&openglThread, &attr, Framework::mainLoop, NULL);
-
-  pthread_attr_destroy(&attr);
-
-  pthread_join( guiThread, (void **)&status);	
-  pthread_join( openglThread, (void **)&status);	
+  //  framework->mainloopGui(NULL);
+
+  framework->mainLoop(NULL);
+
 
   delete framework;
Index: /orxonox/branches/physics/src/subprojects/particles/framework.h
===================================================================
--- /orxonox/branches/physics/src/subprojects/particles/framework.h	(revision 4330)
+++ /orxonox/branches/physics/src/subprojects/particles/framework.h	(revision 4331)
@@ -15,7 +15,8 @@
   Framework();
   static Framework* singletonRef;
-
+  
   Camera* camera;
   
+  bool isFinished;
 
   int movement [4];
@@ -32,4 +33,5 @@
   static Framework* getInstance(void);
 
+
   void initModule();
   static void* mainLoop(void* tmp);
@@ -37,4 +39,5 @@
   float tick();
   bool keyHandler();
+  void quit();
 
   void* initGui(void* argv);
