Browse Source

deadlocks werden nun dadurch verhindert das threads, die sich in critical sections befinden nicht mehr terminiert werden können

kolja 6 years ago
parent
commit
c0f6bbe5cc
30 changed files with 339 additions and 181 deletions
  1. 2 4
      Animation.cpp
  2. 2 1
      Animation.h
  3. 1 0
      Betriebssystem.h
  4. 6 7
      Bildschirm.cpp
  5. 2 1
      Bildschirm.h
  6. 68 0
      Critical.cpp
  7. 33 0
      Critical.h
  8. 75 75
      Diagramm.cpp
  9. 4 3
      Diagramm.h
  10. 6 6
      Fenster.cpp
  11. 2 2
      Fortschritt.cpp
  12. 6 0
      Framework Linux.vcxproj
  13. 6 0
      Framework Linux.vcxproj.filters
  14. 4 1
      Framework.vcxproj
  15. 6 0
      Framework.vcxproj.filters
  16. 2 0
      M2DVorschau.cpp
  17. 16 18
      Model3DList.cpp
  18. 3 1
      Model3DList.h
  19. 2 4
      RenderThread.cpp
  20. 2 1
      RenderThread.h
  21. 2 4
      Schrift.cpp
  22. 2 2
      Schrift.h
  23. 22 24
      TexturList.cpp
  24. 2 1
      TexturList.h
  25. 30 1
      Thread.cpp
  26. 11 0
      Thread.h
  27. 16 18
      Welt3D.cpp
  28. 2 2
      Welt3D.h
  29. 2 4
      Zeichnung.cpp
  30. 2 1
      Zeichnung.h

+ 2 - 4
Animation.cpp

@@ -18,25 +18,23 @@ Animation2DData::Animation2DData()
     transparent( 0 ),
     ref( 1 )
 {
-    InitializeCriticalSection( &cs );
 }
 
 // Destruktor
 Animation2DData::~Animation2DData()
 {
     reset();
-    DeleteCriticalSection( &cs );
 }
 
 // nicht constant
 void Animation2DData::lock()
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
 }
 
 void Animation2DData::unlock()
 {
-    LeaveCriticalSection( &cs );
+    cs.unlock();
 }
 
 void Animation2DData::ladeAnimation( InitDatei *datei )

+ 2 - 1
Animation.h

@@ -2,6 +2,7 @@
 #define Animation_H
 
 #include "Zeichnung.h"
+#include "Critical.h"
 
 namespace Framework
 {
@@ -19,7 +20,7 @@ namespace Framework
         int fps;
         bool wiederhohlen;
         bool transparent;
-        CRITICAL_SECTION cs;
+        Critical cs;
         int ref;
 
     public:

+ 1 - 0
Betriebssystem.h

@@ -74,6 +74,7 @@ private:
 #else
 class CriticalSection;
 #endif
+#define GetCurrentThread               pthread_self
 #define CRITICAL_SECTION               CriticalSection*
 #define InitializeCriticalSection( x ) ( *( x ) ) = new CriticalSection()
 #define DeleteCriticalSection( x )     delete ( *( x ) )

+ 6 - 7
Bildschirm.cpp

@@ -52,7 +52,6 @@ Bildschirm::Bildschirm( WFenster *f )
     fill( 1 ),
     rend( 0 )
 {
-    InitializeCriticalSection( &cs );
 }
 
 // Destruktor 
@@ -61,7 +60,7 @@ Bildschirm::~Bildschirm()
     lock();
     if( renderB )
         renderB->release();
-#ifdef Win32
+#ifdef WIN32
     if( fenster )
         fenster->release();
 #endif
@@ -70,18 +69,17 @@ Bildschirm::~Bildschirm()
     tips->release();
     renderZeit->release();
     unlock();
-    DeleteCriticalSection( &cs );
 }
 
 // nicht konstant 
 void Bildschirm::lock()
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
 }
 
 void Bildschirm::unlock()
 {
-    LeaveCriticalSection( &cs );
+    cs.unlock();
 }
 
 void Bildschirm::setFill( bool f )
@@ -995,14 +993,15 @@ void Bildschirm3D::render() // Zeichnet das Bild
         float screenAspect = (float)backBufferSize.x / (float)backBufferSize.y;
         Mat4< float > view = view.translation( Vec3< float >( 0.f, 0.f, backBufferSize.y * 1.2075f ) );
         renderObj->setKameraMatrix( view, view.projektion( DirectX::XM_PI / 4.0f, screenAspect, 0.1f, 10000.f ), Vec3< float >( 0.f, 0.f, backBufferSize.y * 1.2075f ) );
-        texturModel->render( renderObj );
+        if( fenster && !IsIconic( fenster->getFensterHandle() ) )
+            texturModel->render( renderObj );
 
         result = d3d11SpawChain->Present( 0, 0 );
         renderZeit->messungEnde();
 #ifdef _DEBUG
         std::cout << renderZeit->getSekunden() << "\n";
 #endif
-        if( result != S_OK )
+        if( !SUCCEEDED( result ) )
         {
             ++count;
             update();

+ 2 - 1
Bildschirm.h

@@ -3,6 +3,7 @@
 
 #include "Array.h"
 #include "Punkt.h"
+#include "Critical.h"
 
 // DirectX 11 Types
 
@@ -72,7 +73,7 @@ namespace Framework
         bool rendering;
         ZeitMesser *renderZeit;
         Punkt backBufferSize;
-        CRITICAL_SECTION cs;
+        Critical cs;
         RCArray< ToolTip > *tips;
         int tipAnzahl;
         bool testRend;

+ 68 - 0
Critical.cpp

@@ -0,0 +1,68 @@
+#include "Critical.h"
+#include "Globals.h"
+#include "Thread.h"
+
+using namespace Framework;
+
+// Inhalt der Critical class aus Critical.h
+// Konstructor
+Critical::Critical()
+{
+    InitializeCriticalSection( &cs );
+}
+
+// Destructor
+Critical::~Critical()
+{
+    DeleteCriticalSection( &cs );
+}
+
+// sperrt das Objekt
+void Critical::lock()
+{
+    EnterCriticalSection( &cs );
+    if( !owner )
+        owner = getThreadRegister()->zThread( GetCurrentThread() );
+    if( owner )
+        owner->addCriticalLock();
+    lockCount++;
+}
+
+// versucht das Objekt zu sperren
+bool Critical::tryLock()
+{
+    if( lockCount > 0 )
+        return false;
+    EnterCriticalSection( &cs );
+    if( !owner )
+        owner = getThreadRegister()->zThread( GetCurrentThread() );
+    if( owner )
+        owner->addCriticalLock();
+    lockCount++;
+    return true;
+}
+
+// entsperrt das Objekt
+void Critical::unlock()
+{
+    if( owner && owner->getThreadHandle() != GetCurrentThread() )
+        throw std::runtime_error( "A Thread that does not own a Critical Object trys to unlock it" );
+    if( owner )
+        owner->removeCriticalLock();
+    if( !--lockCount )
+        owner = 0;
+    LeaveCriticalSection( &cs );
+}
+
+
+// gibt true zurück, wenn das Objekt gesperrt ist
+bool Critical::isLocked() const
+{
+    return lockCount > 0;
+}
+
+// gibt einen Zeiger auf den Thread zurück, der das Objekt gesperrt hat
+const Thread *Critical::zOwner() const
+{
+    return owner;
+}

+ 33 - 0
Critical.h

@@ -0,0 +1,33 @@
+#pragma once
+
+#include "Betriebssystem.h"
+
+namespace Framework
+{
+    class Thread;
+
+    class Critical
+    {
+    private:
+        CRITICAL_SECTION cs;
+        Thread *owner;
+        int lockCount;
+
+    public:
+        // Konstructor
+        __declspec( dllexport ) Critical();
+        // Destructor
+        __declspec( dllexport ) ~Critical();
+        // sperrt das Objekt
+        __declspec( dllexport ) void lock();
+        // versucht das Objekt zu sperren
+        __declspec( dllexport ) bool tryLock();
+        // entsperrt das Objekt
+        __declspec( dllexport ) void unlock();
+
+        // gibt true zurück, wenn das Objekt gesperrt ist
+        __declspec( dllexport ) bool isLocked() const;
+        // gibt einen Zeiger auf den Thread zurück, der das Objekt gesperrt hat
+        __declspec( dllexport ) const Thread *zOwner() const;
+    };
+}

+ 75 - 75
Diagramm.cpp

@@ -413,7 +413,7 @@ DiagDaten *DiagDaten::release()
 
 // Inhalt der BaseDiag Klasse aus Diagramm.h
 // Konstruktor
-BaseDiag::BaseDiag( CRITICAL_SECTION *lock )
+BaseDiag::BaseDiag( Critical *lock )
     : daten( new DiagDaten() ),
     changed( 0 ),
     lock( lock ),
@@ -430,17 +430,17 @@ BaseDiag::~BaseDiag()
 // nicht constant
 void BaseDiag::setDiagDatenZ( DiagDaten *dd ) // Setzt einen Zeiger auf die Daten des Diagramms
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( daten )
         daten->release();
     daten = dd;
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
 void BaseDiag::setDiagDaten( DiagDaten *dd ) // Kopiert die Daten eines Diagramms
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     daten->style = dd->style;
@@ -491,97 +491,97 @@ void BaseDiag::setDiagDaten( DiagDaten *dd ) // Kopiert die Daten eines Diagramm
         }
     }
     dd->release();
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
 void BaseDiag::setRasterDicke( int d ) // Rasterdicke setzen
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( daten->rasterDicke != d )
         changed = 1;
     daten->rasterDicke = d;
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setRasterBreite( int br ) // Rasterbreite setzen
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( daten->rasterBreite != br )
         changed = 1;
     daten->rasterBreite = br;
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setRasterHeight( int hi ) // Rasterhöhe setzen
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( daten->rasterHeight != hi )
         changed = 1;
     daten->rasterHeight = hi;
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setRasterFarbe( int f ) // Rasterfarbe setzen
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( daten->rasterFarbe != f )
         changed = 1;
     daten->rasterFarbe = f;
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setHIntervallBreite( double br ) // Intervall Breite
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     daten->hIntervallBreite = br;
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setVIntervallHeight( double hi ) // Intervall Höhe
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     daten->vIntervallHeight = hi;
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setHIntervallFarbe( int f ) // Farbe des Horizontalen Intervalls
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( daten->hIntervallFarbe != f )
         changed = 1;
     daten->hIntervallFarbe = f;
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setVIntervallFarbe( int f ) // Farbe des Vertikalen Intervalls
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( daten->vIntervallFarbe != f )
         changed = 1;
     daten->vIntervallFarbe = f;
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setHIntervallName( char *name ) // Setzt den Namen des Horizontalen Intervalls
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->hIntervallName )
@@ -589,12 +589,12 @@ void BaseDiag::setHIntervallName( char *name ) // Setzt den Namen des Horizontal
     if( !daten->hIntervallName->istGleich( name ) )
         changed = 1;
     daten->hIntervallName->setText( name );
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setHIntervallName( Text *name )
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->hIntervallName )
@@ -602,12 +602,12 @@ void BaseDiag::setHIntervallName( Text *name )
     if( !daten->hIntervallName->istGleich( *name ) )
         changed = 1;
     daten->hIntervallName->setText( name );
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setVIntervallName( char *name ) // Setzt den Namen des Vertikalen Intervalls
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->vIntervallName )
@@ -615,12 +615,12 @@ void BaseDiag::setVIntervallName( char *name ) // Setzt den Namen des Vertikalen
     if( !daten->vIntervallName->istGleich( name ) )
         changed = 1;
     daten->vIntervallName->setText( name );
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::setVIntervallName( Text *name )
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->vIntervallName )
@@ -628,7 +628,7 @@ void BaseDiag::setVIntervallName( Text *name )
     if( !daten->vIntervallName->istGleich( *name ) )
         changed = 1;
     daten->vIntervallName->setText( name );
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::addHIntervallText( double hIntervall, char *text ) // Text eines Horizontalen Intervalls hinzufügen
@@ -644,7 +644,7 @@ void BaseDiag::addHIntervallText( double hIntervall, Text *text )
 
 void BaseDiag::setHIntervallTextZ( double hIntervall, Text *text ) // Setzt den Text eines Horizontalen Intervalls
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->hIntervallWerte )
@@ -657,14 +657,14 @@ void BaseDiag::setHIntervallTextZ( double hIntervall, Text *text ) // Setzt den
         if( daten->hIntervallWerte->hat( i ) && daten->hIntervallWerte->get( i ) == hIntervall )
         {
             daten->hIntervallTexte->set( text, i );
-            LeaveCriticalSection( lock );
+            lock->unlock();
             changed = 1;
             return;
         }
     }
     daten->hIntervallWerte->set( hIntervall, anz );
     daten->hIntervallTexte->set( text, anz );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
@@ -676,7 +676,7 @@ void BaseDiag::setHIntervallText( double hIntervall, Text *text )
 
 void BaseDiag::setHIntervallText( double hIntervall, char *text )
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->hIntervallWerte )
@@ -692,20 +692,20 @@ void BaseDiag::setHIntervallText( double hIntervall, char *text )
                 daten->hIntervallTexte->set( new Text( text ), i );
             else
                 daten->hIntervallTexte->z( i )->setText( text );
-            LeaveCriticalSection( lock );
+            lock->unlock();
             changed = 1;
             return;
         }
     }
     daten->hIntervallWerte->set( hIntervall, anz );
     daten->hIntervallTexte->set( new Text( text ), anz );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
 void BaseDiag::removeHIntervallText( double hIntervall ) // Text eines Horizontalen Intervalls entfernen
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->hIntervallWerte )
@@ -719,12 +719,12 @@ void BaseDiag::removeHIntervallText( double hIntervall ) // Text eines Horizonta
         {
             daten->hIntervallTexte->remove( i );
             daten->hIntervallWerte->remove( i );
-            LeaveCriticalSection( lock );
+            lock->unlock();
             changed = 1;
             return;
         }
     }
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::addVIntervallText( double vIntervall, char *text ) // Text eines Vertikalen Intervalls hinzufügen
@@ -740,7 +740,7 @@ void BaseDiag::addVIntervallText( double vIntervall, Text *text )
 
 void BaseDiag::setVIntervallTextZ( double vIntervall, Text *text ) // Setzt den Text eines Vertikalen Intervalls
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->vIntervallWerte )
@@ -753,14 +753,14 @@ void BaseDiag::setVIntervallTextZ( double vIntervall, Text *text ) // Setzt den
         if( daten->vIntervallWerte->hat( i ) && daten->vIntervallWerte->get( i ) == vIntervall )
         {
             daten->vIntervallTexte->set( text, i );
-            LeaveCriticalSection( lock );
+            lock->unlock();
             changed = 1;
             return;
         }
     }
     daten->vIntervallWerte->set( vIntervall, anz );
     daten->vIntervallTexte->set( text, anz );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
@@ -772,7 +772,7 @@ void BaseDiag::setVIntervallText( double vIntervall, Text *text )
 
 void BaseDiag::setVIntervallText( double vIntervall, char *text )
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->vIntervallWerte )
@@ -788,20 +788,20 @@ void BaseDiag::setVIntervallText( double vIntervall, char *text )
                 daten->vIntervallTexte->set( new Text( text ), i );
             else
                 daten->vIntervallTexte->z( i )->setText( text );
-            LeaveCriticalSection( lock );
+            lock->unlock();
             changed = 1;
             return;
         }
     }
     daten->vIntervallWerte->set( vIntervall, anz );
     daten->vIntervallTexte->set( new Text( text ), anz );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
 void BaseDiag::removeVIntervallText( double vIntervall ) // Text eines Vertikalen Intervalls entfernen
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->vIntervallWerte )
@@ -815,29 +815,29 @@ void BaseDiag::removeVIntervallText( double vIntervall ) // Text eines Vertikale
         {
             daten->vIntervallTexte->remove( i );
             daten->vIntervallWerte->remove( i );
-            LeaveCriticalSection( lock );
+            lock->unlock();
             changed = 1;
             return;
         }
     }
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::addWertZ( DiagWert *w ) // Fügt einen Wert hinzu
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
         daten->werte = new RCArray< DiagWert >();
     daten->werte->add( w );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
 void BaseDiag::addWert( DiagWert *w )
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     DiagWert *tmp = new DiagWert();
     tmp->style = w->style;
     tmp->farbe = w->farbe;
@@ -856,13 +856,13 @@ void BaseDiag::addWert( DiagWert *w )
     }
     w->release();
     addWertZ( tmp );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
 void BaseDiag::addWert( const char *name )
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
@@ -870,7 +870,7 @@ void BaseDiag::addWert( const char *name )
     DiagWert *w = new DiagWert();
     w->name->setText( name );
     daten->werte->add( w );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
@@ -884,7 +884,7 @@ void BaseDiag::setWertFarbe( int wNum, int f ) // setzt die Farbe eines Wertes
 {
     if( wNum < 0 )
         return;
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
@@ -892,7 +892,7 @@ void BaseDiag::setWertFarbe( int wNum, int f ) // setzt die Farbe eines Wertes
     if( !daten->werte->z( wNum ) )
         daten->werte->set( new DiagWert(), wNum );
     daten->werte->z( wNum )->farbe = f;
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
@@ -900,7 +900,7 @@ void BaseDiag::addPunktZ( int wNum, DiagPunkt *p ) // f
 {
     if( wNum < 0 )
         return;
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
@@ -910,7 +910,7 @@ void BaseDiag::addPunktZ( int wNum, DiagPunkt *p ) // f
     if( !daten->werte->z( wNum )->punkte )
         daten->werte->z( wNum )->punkte = new Array< DiagPunkt* >();
     daten->werte->z( wNum )->punkte->add( p );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
@@ -918,7 +918,7 @@ void BaseDiag::addPunkt( int wNum, DiagPunkt *p )
 {
     if( wNum < 0 )
         return;
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
@@ -931,7 +931,7 @@ void BaseDiag::addPunkt( int wNum, DiagPunkt *p )
     tmp->hIntervall = p->hIntervall;
     tmp->vIntervall = p->vIntervall;
     daten->werte->z( wNum )->punkte->add( tmp );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
@@ -939,7 +939,7 @@ void BaseDiag::addPunkt( int wNum, double hI, double vI )
 {
     if( wNum < 0 )
         return;
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
@@ -952,7 +952,7 @@ void BaseDiag::addPunkt( int wNum, double hI, double vI )
     tmp->hIntervall = hI;
     tmp->vIntervall = vI;
     daten->werte->z( wNum )->punkte->add( tmp );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
@@ -976,7 +976,7 @@ void BaseDiag::setPunktZ( int wNum, int pNum, DiagPunkt *p )
 {
     if( pNum < 0 || wNum < 0 )
         return;
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
@@ -988,7 +988,7 @@ void BaseDiag::setPunktZ( int wNum, int pNum, DiagPunkt *p )
     if( daten->werte->z( wNum )->punkte->hat( pNum ) )
         delete daten->werte->z( wNum )->punkte->get( pNum );
     daten->werte->z( wNum )->punkte->set( p, pNum );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
@@ -1003,7 +1003,7 @@ void BaseDiag::setPunkt( int wNum, int pNum, double h, double v )
 {
     if( pNum < 0 || wNum < 0 )
         return;
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
@@ -1016,14 +1016,14 @@ void BaseDiag::setPunkt( int wNum, int pNum, double h, double v )
         daten->werte->z( wNum )->punkte->set( new DiagPunkt(), pNum );
     daten->werte->z( wNum )->punkte->get( pNum )->hIntervall = h;
     daten->werte->z( wNum )->punkte->get( pNum )->vIntervall = v;
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
 // Löscht einen vorhandenen Punkt
 void BaseDiag::removePunkt( int wNum, double hI )
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
@@ -1039,17 +1039,17 @@ void BaseDiag::removePunkt( int wNum, double hI )
         {
             delete daten->werte->z( wNum )->punkte->get( i );
             daten->werte->z( wNum )->punkte->remove( i );
-            LeaveCriticalSection( lock );
+            lock->unlock();
             changed = 1;
             return;
         }
     }
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::removePunkt( int wNum, int pNum )
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
@@ -1064,24 +1064,24 @@ void BaseDiag::removePunkt( int wNum, int pNum )
         daten->werte->z( wNum )->punkte->remove( pNum );
         changed = 1;
     }
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::removeWert( int wNum ) // entfernt einen Wert
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
         daten->werte = new RCArray< DiagWert >();
     daten->werte->remove( wNum );
-    LeaveCriticalSection( lock );
+    lock->unlock();
     changed = 1;
 }
 
 void BaseDiag::removeWert( char *name )
 {
-    EnterCriticalSection( lock );
+    lock->lock();
     if( !daten )
         daten = new DiagDaten();
     if( !daten->werte )
@@ -1093,12 +1093,12 @@ void BaseDiag::removeWert( char *name )
         if( tmp && tmp->name && tmp->name->istGleich( name ) )
         {
             daten->werte->remove( i );
-            LeaveCriticalSection( lock );
+            lock->unlock();
             changed = 1;
             return;
         }
     }
-    LeaveCriticalSection( lock );
+    lock->unlock();
 }
 
 void BaseDiag::removeWert( Text *name )

+ 4 - 3
Diagramm.h

@@ -3,6 +3,7 @@
 
 #include "Zeichnung.h"
 #include "Array.h"
+#include "Critical.h"
 
 namespace Framework
 {
@@ -242,13 +243,13 @@ namespace Framework
     protected:
         DiagDaten *daten;
         bool changed;
-        CRITICAL_SECTION *lock;
+        Critical *lock;
         int ref;
 
     public:
         // Konstruktor
-        //  lock: Ein Zeiger zur CRITICAL_SECTION, mit der die Diagramm Klasse, die von dieser Klasse erbt Multithread sicher gemacht wird
-        __declspec( dllexport ) BaseDiag( CRITICAL_SECTION *lock );
+        //  lock: Ein Zeiger zur Critical, mit der die Diagramm Klasse, die von dieser Klasse erbt Multithread sicher gemacht wird
+        __declspec( dllexport ) BaseDiag( Critical *lock );
         // Destruktor
         __declspec( dllexport ) virtual ~BaseDiag();
         // Setzt einen Zeiger auf die Daten des Diagramms

+ 6 - 6
Fenster.cpp

@@ -522,7 +522,7 @@ void WFenster::setPosition( Punkt &p )// Fenster Position
     RECT res;
     res.left = p.x, res.top = p.y, res.right = r.right - r.left, res.bottom = r.bottom - r.top;
     AdjustWindowRect( &res, style, 0 );
-    if( res.top < 0 )
+/*    if( res.top < 0 )
     {
         res.bottom -= res.top;
         res.top = 0;
@@ -531,7 +531,7 @@ void WFenster::setPosition( Punkt &p )// Fenster Position
     {
         res.right -= res.left;
         res.left = 0;
-    }
+    }*/
     SetWindowPos( hWnd, 0, res.left, res.top, res.right, res.bottom, 0 ); // Position ändern
 }
 
@@ -542,7 +542,7 @@ void WFenster::setSize( Punkt &g )// Fenster Gr
     RECT res;
     res.left = r.left, res.top = r.top, res.right = g.x, res.bottom = g.y;
     AdjustWindowRect( &res, style, 0 );
-    if( res.top < 0 )
+/*    if( res.top < 0 )
     {
         res.bottom -= res.top;
         res.top = 0;
@@ -551,7 +551,7 @@ void WFenster::setSize( Punkt &g )// Fenster Gr
     {
         res.right -= res.left;
         res.left = 0;
-    }
+    }*/
     SetWindowPos( hWnd, 0, res.left, res.top, res.right, res.bottom, 0 ); // Größe ändern
 }
 
@@ -562,7 +562,7 @@ void WFenster::setSize( int breite, int h
     RECT res;
     res.left = r.left, res.top = r.top, res.right = breite, res.bottom = höhe;
     AdjustWindowRect( &res, style, 0 );
-    if( res.top < 0 )
+/*    if( res.top < 0 )
     {
         res.bottom -= res.top;
         res.top = 0;
@@ -571,7 +571,7 @@ void WFenster::setSize( int breite, int h
     {
         res.right -= res.left;
         res.left = 0;
-    }
+    }*/
     SetWindowPos( hWnd, 0, res.left, res.top, res.right, res.bottom, 0 ); // Größe ändern
 }
 

+ 2 - 2
Fortschritt.cpp

@@ -210,9 +210,9 @@ void FBalken::render( Bild &zRObj ) // zeichnet nach zRObj
     if( hatStyle( Style::FBild ) && fBgBild )
     {
         if( hatStyle( Style::FAlpha ) )
-            zRObj.alphaBildSkall( rbr, rbr, b - rbr * 2, h - rbr * 2, *fBgBild );
+            zRObj.alphaBildSkall( rbr, rbr, gr.x - rbr * 2, gr.y - rbr * 2, *fBgBild );
         else
-            zRObj.drawBildSkall( rbr, rbr, b - rbr * 2, h - rbr * 2, *fBgBild );
+            zRObj.alphaBildSkall( rbr, rbr, gr.x - rbr * 2, gr.y - rbr * 2, *fBgBild );
     }
     if( hatStyle( Style::FBuffered ) && fBuffer )
     {

+ 6 - 0
Framework Linux.vcxproj

@@ -82,11 +82,15 @@
     <RemoteProjectDir>$(RemoteRootDir)/Framework/debug</RemoteProjectDir>
     <TargetName>libdbgFramework</TargetName>
     <IncludePath>D:\Visual Studio 2017\Common7\IDE\VC\Linux\include\usr\include\c++\5;$(IncludePath)</IncludePath>
+    <OutDir>$(ProjectDir)bin\$(Platform)\debug\</OutDir>
+    <IntDir>$(ProjectDir)obj\$(Platform)\debug\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <TargetExt>.so</TargetExt>
     <RemoteProjectDir>$(RemoteRootDir)/Framework/release</RemoteProjectDir>
     <TargetName>libFramework</TargetName>
+    <OutDir>$(ProjectDir)bin\$(Platform)\release\</OutDir>
+    <IntDir>$(ProjectDir)obj\$(Platform)\release\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
     <TargetExt>.so</TargetExt>
@@ -103,6 +107,7 @@
     <ClCompile Include="AuswahlBox.cpp" />
     <ClCompile Include="Bild.cpp" />
     <ClCompile Include="Bildschirm.cpp" />
+    <ClCompile Include="Critical.cpp" />
     <ClCompile Include="Cube.cpp" />
     <ClCompile Include="Datei.cpp" />
     <ClCompile Include="DateiSystem.cpp" />
@@ -151,6 +156,7 @@
     <ClInclude Include="Betriebssystem.h" />
     <ClInclude Include="Bild.h" />
     <ClInclude Include="Bildschirm.h" />
+    <ClInclude Include="Critical.h" />
     <ClInclude Include="Cube.h" />
     <ClInclude Include="Datei.h" />
     <ClInclude Include="DateiSystem.h" />

+ 6 - 0
Framework Linux.vcxproj.filters

@@ -234,6 +234,9 @@
     <ClInclude Include="DXBuffer.h">
       <Filter>Headerdateien\Framework\Grafik\DX</Filter>
     </ClInclude>
+    <ClInclude Include="Critical.h">
+      <Filter>Headerdateien\Framework\OS</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Prozess.cpp">
@@ -365,5 +368,8 @@
     <ClCompile Include="DXBuffer.cpp">
       <Filter>Quelldateien\Framework\Grafik\DX</Filter>
     </ClCompile>
+    <ClCompile Include="Critical.cpp">
+      <Filter>Quelldateien\Framework\OS</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 4 - 1
Framework.vcxproj

@@ -133,7 +133,8 @@ copy "x64\Debug\Framework.dll" "..\..\Spiele Platform\Klient\patcher\patcher\fra
 copy "x64\Debug\Framework.dll" "..\..\Spiele Platform\Klient\Icon\Icon\framework.dll"
 copy "x64\Debug\Framework.dll" "..\..\Spiele Platform\SMP\SMP\framework.dll"
 copy "x64\Debug\Framework.dll" "..\LTDB Konverter\LTDB Konverter\framework.dll"
-copy "x64\Debug\Framework.dll" "..\GSL Konverter\GSL Konverter\framework.dll"</Command>
+copy "x64\Debug\Framework.dll" "..\GSL Konverter\GSL Konverter\framework.dll"
+copy "x64\Debug\Framework.dll" "..\..\Spiele Platform\Klient\Fertig\Debug\x64\framework.dll"</Command>
       <Outputs>kopiere Dateien...;%(Outputs)</Outputs>
     </CustomBuildStep>
     <Bscmake>
@@ -202,6 +203,7 @@ copy "x64\Release\Framework.dll" "..\..\Spiele Platform\SMP\Fertig\x64\framework
     <ClInclude Include="AuswahlBox.h" />
     <ClInclude Include="Bild.h" />
     <ClInclude Include="Bildschirm.h" />
+    <ClInclude Include="Critical.h" />
     <ClInclude Include="Cube.h" />
     <ClInclude Include="DXBuffer.h" />
     <ClInclude Include="Datei.h" />
@@ -264,6 +266,7 @@ copy "x64\Release\Framework.dll" "..\..\Spiele Platform\SMP\Fertig\x64\framework
     <ClCompile Include="AuswahlBox.cpp" />
     <ClCompile Include="Bild.cpp" />
     <ClCompile Include="Bildschirm.cpp" />
+    <ClCompile Include="Critical.cpp" />
     <ClCompile Include="Cube.cpp" />
     <ClCompile Include="Datei.cpp" />
     <ClCompile Include="DateiDialog.cpp" />

+ 6 - 0
Framework.vcxproj.filters

@@ -258,6 +258,9 @@
     <ClInclude Include="Key.h">
       <Filter>Headerdateien\Framework</Filter>
     </ClInclude>
+    <ClInclude Include="Critical.h">
+      <Filter>Headerdateien\Framework\OS</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Maus.cpp">
@@ -407,5 +410,8 @@
     <ClCompile Include="Key.cpp">
       <Filter>Quelldateien\Framework</Filter>
     </ClCompile>
+    <ClCompile Include="Critical.cpp">
+      <Filter>Quelldateien\Framework\OS</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 2 - 0
M2DVorschau.cpp

@@ -19,6 +19,8 @@ M2DVorschau::M2DVorschau()
     mdl = 0;
     mx = -1;
     my = -1;
+    af = 0;
+    ram = 0;
     ref = 1;
 }
 

+ 16 - 18
Model3DList.cpp

@@ -5,7 +5,7 @@
 using namespace Framework;
 
 int Model3DList::id = 0;
-CRITICAL_SECTION Model3DList::cs;
+Critical Model3DList::cs;
 
 const char *Standart3DTypes::cube = "f_würfel";
 
@@ -30,20 +30,20 @@ Model3DList::~Model3DList()
 //  name: Der name, unter dem das Model in der Liste gespeichert wird
 bool Model3DList::addModel( Model3DData *mdl, const char *name )
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     for( auto i = names->getArray(); i.set; i++ )
     {
         if( i.var->istGleich( name ) )
         {
             mdl->release();
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return 0;
         }
     }
     mdl->id = id++;
     models->add( mdl );
     names->add( new Text( name ) );
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return 1;
 }
 
@@ -51,7 +51,7 @@ bool Model3DList::addModel( Model3DData *mdl, const char *name )
 //  name: Der Name des Models
 void Model3DList::removeModel( const char *name )
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     int index = 0;
     for( auto i = names->getArray(); i.set; i++ )
     {
@@ -59,12 +59,12 @@ void Model3DList::removeModel( const char *name )
         {
             names->remove( index );
             models->remove( index );
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return;
         }
         index++;
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
 }
 
 // Überprüft, ob unter einem bestimmten Namen ein Model abgespeichert wurde
@@ -72,16 +72,16 @@ void Model3DList::removeModel( const char *name )
 //  return: true, wenn ein Model mit dem Namen existiert
 bool Model3DList::hatModel( const char *name ) const
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     for( auto i = names->getArray(); i.set; i++ )
     {
         if( i.var->istGleich( name ) )
         {
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return 1;
         }
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return 0;
 }
 
@@ -89,18 +89,18 @@ bool Model3DList::hatModel( const char *name ) const
 //  name: Der Name des Models
 Model3DData *Model3DList::getModel( const char *name ) const
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     int index = 0;
     for( auto i = names->getArray(); i.set; i++ )
     {
         if( i.var->istGleich( name ) )
         {
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return models->get( index );
         }
         index++;
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return 0;
 }
 
@@ -108,18 +108,18 @@ Model3DData *Model3DList::getModel( const char *name ) const
 //  name: Der Name des Models
 Model3DData *Model3DList::zModel( const char *name ) const
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     int index = 0;
     for( auto i = names->getArray(); i.set; i++ )
     {
         if( i.var->istGleich( name ) )
         {
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return models->z( index );
         }
         index++;
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return 0;
 }
 
@@ -147,11 +147,9 @@ Model3DList *Model3DList::release()
 void Model3DList::init()
 {
     id = 0;
-    InitializeCriticalSection( &cs );
 }
 
 // Löscht statische private member. Wird vom Framework automatisch aufgerufen.
 void Model3DList::destroy()
 {
-    DeleteCriticalSection( &cs );
 }

+ 3 - 1
Model3DList.h

@@ -1,12 +1,14 @@
 #pragma once
 
 #include "Array.h"
+#include "Critical.h"
 
 namespace Framework
 {
     class Model3DData; // Model3D.h
     class Text; // Text.h
     class Model3D; // Model3D.h
+
     namespace Standart3DTypes
     {
         extern const char *cube; // = "f_würfel"; Die Modeldaten eines Würfels der 100 * 100 * 100 groß ist
@@ -17,7 +19,7 @@ namespace Framework
     {
     private:
         static int id;
-        static CRITICAL_SECTION cs;
+        static Critical cs;
         RCArray< Model3DData > *models;
         RCArray< Text > *names;
         int ref;

+ 2 - 4
RenderThread.cpp

@@ -19,7 +19,6 @@ RenderTh::RenderTh()
     maxFps( 30 ),
     ref( 1 )
 {
-    InitializeCriticalSection( &cs );
 }
 
 // Destruktor 
@@ -30,18 +29,17 @@ RenderTh::~RenderTh()
     if( bildschirm )
         bildschirm->release();
     zeit->release();
-    DeleteCriticalSection( &cs );
 }
 
 // nicht constant 
 void RenderTh::lock()
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
 }
 
 void RenderTh::unlock()
 {
-    LeaveCriticalSection( &cs );
+    cs.unlock();
 }
 
 void RenderTh::setBildschirm( Bildschirm *bildschirm ) // setzt den Bildschirm

+ 2 - 1
RenderThread.h

@@ -2,6 +2,7 @@
 #define RenderThread_H
 
 #include "Thread.h"
+#include "Critical.h"
 
 namespace Framework
 {
@@ -22,7 +23,7 @@ namespace Framework
         void( *renderFunktion )( void *, void *, Bild * );
         void( *tickFunktion )( void *, void *, double );
         bool pause;
-        CRITICAL_SECTION cs;
+        Critical cs;
         int maxFps;
         int ref;
 

+ 2 - 4
Schrift.cpp

@@ -742,25 +742,23 @@ Schrift::Schrift()
     drawPos( 0, 0 ),
     ref( 1 )
 {
-    InitializeCriticalSection( &cs );
 }
 
 // Destruktor 
 Schrift::~Schrift()
 {
     delete alphabet;
-    DeleteCriticalSection( &cs );
 }
 
 // nicht constant 
 void Schrift::lock() // lockt die Schrift
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
 }
 
 void Schrift::unlock() // unlockt die Schrift
 {
-    LeaveCriticalSection( &cs );
+    cs.unlock();
 }
 
 bool Schrift::addAlphabet( Alphabet *alphabet ) // Fügt der Schrift ein Alphabet hinzu

+ 2 - 2
Schrift.h

@@ -1,7 +1,7 @@
 #ifndef Schrift_H
 #define Schrift_H
 
-#include "Betriebssystem.h"
+#include "Critical.h"
 #include "Punkt.h"
 
 namespace Framework
@@ -255,7 +255,7 @@ namespace Framework
         int schriftSize;
         int zeilenAbstand;
         Punkt drawPos;
-        CRITICAL_SECTION cs;
+        Critical cs;
         int ref;
 
     public:

+ 22 - 24
TexturList.cpp

@@ -5,7 +5,7 @@
 using namespace Framework;
 
 int TexturList::id = 0;
-CRITICAL_SECTION TexturList::cs;
+Critical TexturList::cs;
 
 // Inhalt der TexturList Klasse
 // Konstruktor
@@ -28,20 +28,20 @@ TexturList::~TexturList()
 //  name: Der name, unter dem die Textur in der Liste gespeichert wird
 bool TexturList::addTextur( Textur *t, const char *name )
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     for( auto i = names->getArray(); i.set; i++ )
     {
         if( i.var->istGleich( name ) )
         {
             t->release();
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return 0;
         }
     }
     t->id = id++;
     textures->add( t );
     names->add( new Text( name ) );
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return 1;
 }
 
@@ -49,7 +49,7 @@ bool TexturList::addTextur( Textur *t, const char *name )
 //  name: Der Name der Textur
 void TexturList::removeTextur( const char *name )
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     int index = 0;
     for( auto i = names->getArray(); i.set; i++ )
     {
@@ -57,12 +57,12 @@ void TexturList::removeTextur( const char *name )
         {
             names->remove( index );
             textures->remove( index );
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return;
         }
         index++;
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
 }
 
 // Überprüft, ob unter einem bestimmten Namen eine Textur abgespeichert wurde
@@ -70,16 +70,16 @@ void TexturList::removeTextur( const char *name )
 //  return: true, wenn eine Textur mit dem Namen existiert
 bool TexturList::hatTextur( const char *name ) const
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     for( auto i = names->getArray(); i.set; i++ )
     {
         if( i.var->istGleich( name ) )
         {
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return 1;
         }
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return 0;
 }
 
@@ -87,18 +87,18 @@ bool TexturList::hatTextur( const char *name ) const
 //  name: Der Name der Textur
 Textur *TexturList::getTextur( const char *name ) const
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     int index = 0;
     for( auto i = names->getArray(); i.set; i++ )
     {
         if( i.var->istGleich( name ) )
         {
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return textures->get( index );
         }
         index++;
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return 0;
 }
 
@@ -106,16 +106,16 @@ Textur *TexturList::getTextur( const char *name ) const
 //  id: Die Id der Textur
 Textur *TexturList::getTextur( int id ) const
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     for( auto i = textures->getArray(); i.set; i++ )
     {
         if( i.var->getId() == id )
         {
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return i.var->getThis();
         }
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return 0;
 }
 
@@ -123,18 +123,18 @@ Textur *TexturList::getTextur( int id ) const
 //  name: Der Name der Textur
 Textur *TexturList::zTextur( const char *name ) const
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     int index = 0;
     for( auto i = names->getArray(); i.set; i++ )
     {
         if( i.var->istGleich( name ) )
         {
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return textures->z( index );
         }
         index++;
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return 0;
 }
 
@@ -142,16 +142,16 @@ Textur *TexturList::zTextur( const char *name ) const
 //  id: Die Id der Textur
 Textur *TexturList::zTextur( int id ) const
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     for( auto i = textures->getArray(); i.set; i++ )
     {
         if( i.var->getId() == id )
         {
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return i.var;
         }
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return 0;
 }
 
@@ -179,11 +179,9 @@ TexturList *TexturList::release()
 void TexturList::init()
 {
     id = 0;
-    InitializeCriticalSection( &cs );
 }
 
 // Löscht statische private member. Wird vom Framework automatisch aufgerufen.
 void TexturList::destroy()
 {
-    DeleteCriticalSection( &cs );
 }

+ 2 - 1
TexturList.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include "Array.h"
+#include "Critical.h"
 
 namespace Framework
 {
@@ -11,7 +12,7 @@ namespace Framework
     {
     private:
         static int id;
-        static CRITICAL_SECTION cs;
+        static Critical cs;
         RCArray< Textur > *textures;
         RCArray< Text > *names;
         int ref;

+ 30 - 1
Thread.cpp

@@ -19,7 +19,7 @@ Thread::~Thread()
 {
     thRegister->remove( this );
 #ifdef WIN32
-    if( GetCurrentThreadId() == GetThreadId( threadHandle ) )
+    if( threadHandle != 0 && GetCurrentThreadId() == GetThreadId( threadHandle ) )
         return;
 #else
     if( pthread_self() == threadHandle )
@@ -63,6 +63,8 @@ void Thread::ende() // beendet den Thread
 {
     if( run )
     {
+        while( lockCount > 0 )
+            Sleep( 100 );
 #ifdef WIN32
 #pragma warning(suppress: 6258)
         TerminateThread( threadHandle, 0 );
@@ -126,6 +128,16 @@ pthread_t Thread::getThreadHandle() const
     return threadHandle;
 }
 
+void Thread::addCriticalLock()
+{
+    lockCount++;
+}
+
+void Thread::removeCriticalLock()
+{
+    lockCount--;
+}
+
 // funktionen 
 #ifdef WIN32
 unsigned long __stdcall Framework::threadStart( void *param )
@@ -197,6 +209,23 @@ void ThreadRegister::addClosedThread( pthread_t handle )
     LeaveCriticalSection( &cs );
 }
 
+// Sucht nach einem bestimmten Thread und gibt das zugehörige Objekt zurück
+// handle: Ein handle zu dem gesuchten Thread
+Thread *ThreadRegister::zThread( pthread_t handle )
+{
+    EnterCriticalSection( &cs );
+    for( auto i = threads.getArray(); i.set; i++ )
+    {
+        if( i.var->getThreadHandle() == handle )
+        {
+            LeaveCriticalSection( &cs );
+            return i.var;
+        }
+    }
+    LeaveCriticalSection( &cs );
+    return 0;
+}
+
 // Löscht die bereits beendetetn Threads und gibt ihre Reccourcen wieder frei
 void ThreadRegister::cleanUpClosedThreads()
 {

+ 11 - 0
Thread.h

@@ -6,12 +6,14 @@
 namespace Framework
 {
     class Thread;
+    class Critical;
 
     // Ein neuer Thread wie die Thread Klasse aus Java
     class Thread
     {
     private:
         pthread_t *threadHandleSys;
+        int lockCount;
     protected:
         unsigned long threadId;
         pthread_t threadHandle;
@@ -48,6 +50,12 @@ namespace Framework
         void setSystemHandlePointer( pthread_t *ths );
         // Gibt ein Handle auf den Thread zurück
         __declspec( dllexport ) pthread_t getThreadHandle() const;
+
+    private:
+        void addCriticalLock();
+        void removeCriticalLock();
+
+    friend Critical;
     };
 
 #ifdef WIN32
@@ -80,6 +88,9 @@ namespace Framework
         // Überprüft, ob ein Zeiger auf ein gültiges Thread Objekt zeigt, oder ob es schon gelöscht wurde
         //  t: Der Zeiger, der geprüft werden soll
         bool isThread( Thread *t );
+        // Sucht nach einem bestimmten Thread und gibt das zugehörige Objekt zurück
+        // handle: Ein handle zu dem gesuchten Thread
+        Thread *zThread( pthread_t handle );
         // Setzt Wird automatisch aufgerufen, wenn ein Thread beendet wird. Die Reccourcen werden daraufhin in cleanUpClosedThreads freigegeben.
         //  handle: Das Handle des Threads
         void addClosedThread( pthread_t handle );

+ 16 - 18
Welt3D.cpp

@@ -11,7 +11,6 @@ using namespace Framework;
 // Konstructor
 Welt3D::Welt3D()
 {
-    InitializeCriticalSection( &cs );
     arraySize = 100;
     arraySizeAlpha = 100;
     members = new Zeichnung3D*[ arraySize ];
@@ -38,14 +37,13 @@ Welt3D::~Welt3D()
     delete[] distSqSort;
     delete[] alphaVS;
     delete[] elementsSort;
-    DeleteCriticalSection( &cs );
 }
 
 // Fügt der Welt ein Objekt hinzu
 //  obj: Das Objekt, was hinzugefügt werden soll
 void Welt3D::addZeichnung( Zeichnung3D *obj )
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     Zeichnung3D **tmp = members;
     int max = arraySize;
     if( obj->hatAlpha() )
@@ -58,7 +56,7 @@ void Welt3D::addZeichnung( Zeichnung3D *obj )
         if( !*tmp )
         {
             *tmp = obj;
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return;
         }
         tmp++;
@@ -81,7 +79,7 @@ void Welt3D::addZeichnung( Zeichnung3D *obj )
         distSqSort= new float[ arraySizeAlpha + arraySize ];
         alphaVS = new Zeichnung3D*[ arraySizeAlpha + arraySize ];
         elementsSort = new Zeichnung3D*[ arraySizeAlpha + arraySize ];
-        LeaveCriticalSection( &cs );
+        cs.unlock();
         return;
     }
     arraySize += 100;
@@ -99,14 +97,14 @@ void Welt3D::addZeichnung( Zeichnung3D *obj )
     distSqSort = new float[ arraySizeAlpha + arraySize ];
     alphaVS = new Zeichnung3D*[ arraySizeAlpha + arraySize ];
     elementsSort = new Zeichnung3D*[ arraySizeAlpha + arraySize ];
-    LeaveCriticalSection( &cs );
+    cs.unlock();
 }
 
 // Entfernt ein Objekt aus der Welt
 //  obj: Das Objekt, das entwernt werden soll
 void Welt3D::removeZeichnung( Zeichnung3D *obj )
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
     int index = 0;
     if( !obj->hatAlpha() )
     {
@@ -116,11 +114,11 @@ void Welt3D::removeZeichnung( Zeichnung3D *obj )
             {
                 *i = 0;
                 rend = 1;
-                LeaveCriticalSection( &cs );
+                cs.unlock();
                 return;
             }
         }
-        LeaveCriticalSection( &cs );
+        cs.unlock();
         return;
     }
     for( Zeichnung3D **i = membersAlpha; index < arraySizeAlpha; i++, index++ )
@@ -129,18 +127,18 @@ void Welt3D::removeZeichnung( Zeichnung3D *obj )
         {
             *i = 0;
             rend = 1;
-            LeaveCriticalSection( &cs );
+            cs.unlock();
             return;
         }
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
 }
 
 // Verarbeitet ein Mausereignis
 //  me: Das Mausereignis, das verarbeitet werden soll
 void Welt3D::doMausEreignis( MausEreignis3D &me )
 {
-    //EnterCriticalSection( &cs );
+    //cs.lock()
     //int anz = 0;
     //int index = 0;
     //for( Zeichnung3D **i = members; index < arraySize; i++, index++ )
@@ -181,13 +179,13 @@ void Welt3D::doMausEreignis( MausEreignis3D &me )
     //        alphaVS[ ind ]->doMausEreignis( me );
     //        if( me.verarbeitet )
     //        {
-    //            LeaveCriticalSection( &cs );
+    //            cs.unlock();
     //            return;
     //        }
     //        used[ ind ] = 1;
     //    }
     //} while( ind >= 0 );
-    //LeaveCriticalSection( &cs );
+    //cs.unlock();
 }
 
 // Verarbeitet die vergangene Zeit
@@ -200,7 +198,7 @@ bool Welt3D::tick( double tickval )
     rend = 0;
     upd = 0;
     int index = 0;
-    EnterCriticalSection( &cs );
+    cs.lock();
     for( Zeichnung3D **i = members; index < arraySize; i++, index++ )
     {
         if( *i && ( *i )->hatAlpha() )
@@ -222,7 +220,7 @@ bool Welt3D::tick( double tickval )
             continue;
         }
     }
-    LeaveCriticalSection( &cs );
+    cs.unlock();
     return rend;
 }
 
@@ -232,7 +230,7 @@ void Welt3D::render( Render3D *zRObj )
 {
 #ifdef WIN32
     upd = 1;
-	EnterCriticalSection( &cs );
+    cs.lock();
     int index = 0;
     for( Zeichnung3D **i = members; index < arraySize; i++, index++ )
     {
@@ -313,7 +311,7 @@ void Welt3D::render( Render3D *zRObj )
     }
     for( int i = index2 - 1; i >= 0; i-- )
         alphaVS[ i ]->render( zRObj );
-    LeaveCriticalSection( &cs );
+    cs.unlock();
 #endif
 }
 

+ 2 - 2
Welt3D.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "Betriebssystem.h"
+#include "Critical.h"
 
 namespace Framework
 {
@@ -23,7 +23,7 @@ namespace Framework
         int arraySizeAlpha;
         bool rend;
         bool upd;
-        CRITICAL_SECTION cs;
+        Critical cs;
         int ref;
 
     public:

+ 2 - 4
Zeichnung.cpp

@@ -31,13 +31,11 @@ Zeichnung::Zeichnung()
     toolTip( 0 ),
     rend( 0 )
 {
-    InitializeCriticalSection( &cs );
 }
 
 // Destruktor 
 Zeichnung::~Zeichnung()
 {
-    DeleteCriticalSection( &cs );
     if( toolTip )
         toolTip->release();
 }
@@ -62,12 +60,12 @@ void Zeichnung::setToolTipText( const char *txt, Bildschirm *zScreen )
 
 void Zeichnung::lockZeichnung()
 {
-    EnterCriticalSection( &cs );
+    cs.lock();
 }
 
 void Zeichnung::unlockZeichnung()
 {
-    LeaveCriticalSection( &cs );
+    cs.unlock();
 }
 
 void Zeichnung::setMausEreignisParameter( void *p ) // setzt den Parameter vom Maus Ereignis

+ 2 - 1
Zeichnung.h

@@ -2,6 +2,7 @@
 #define Zeichnung_H
 
 #include "Punkt.h"
+#include "Critical.h"
 
 namespace Framework
 {
@@ -42,7 +43,7 @@ namespace Framework
         bool( *nMak )( void *, void *, MausEreignis );
         bool( *nTak )( void *, void *, TastaturEreignis );
         bool mausIn;
-        CRITICAL_SECTION cs;
+        Critical cs;
         ToolTip *toolTip;
         __int64 style;
         bool rend;