Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 26, 2007, 7:22:06 PM (16 years ago)
Author:
rgrieder
Message:
  • replaced a little hack in DebugLevel through a tiny one.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/orxonox/core/DebugLevel.cc

    r684 r686  
    3737namespace orxonox
    3838{
    39     DebugLevel* DebugLevel::pointer_s = 0;                // Set the static member variable pointer_s to zero
    40     bool DebugLevel::bCreatingDebugLevelObject_s = false; // Set the static member variable bCreatingDebugLevelObject_s to false
    41 
    4239    /**
    4340        @brief Constructor: Registers the object and sets the debug level.
     
    4542    DebugLevel::DebugLevel()
    4643    {
     44        this->softDebugLevel_ = 4;   // accounts for the recursive call when creating the object
    4745        RegisterRootObject(DebugLevel);
    48         SetConfigValue(softDebugLevel_s, 2);
     46        SetConfigValue(softDebugLevel_, 2);
    4947    }
    5048
     
    5452    int DebugLevel::getSoftDebugLevel()
    5553    {
    56         if (!pointer_s && !bCreatingDebugLevelObject_s)
    57         {
    58             // We need the bCreatingDebugLevelObject_s variable to avoid an infinite recursion:
    59             // Creating the object produces debug output and debug output needs the object.
    60             bCreatingDebugLevelObject_s = true;
    61             pointer_s = new DebugLevel;
    62             bCreatingDebugLevelObject_s = false;
    63         }
    64         else if (bCreatingDebugLevelObject_s)
    65             return 4;
    66 
    67         return pointer_s->softDebugLevel_s;
     54        static DebugLevel theOneAndOnlyInstance = DebugLevel();
     55        return theOneAndOnlyInstance.softDebugLevel_;
    6856    }
    6957}
Note: See TracChangeset for help on using the changeset viewer.