Changeset 443 for cafu/trunk

Show
Ignore:
Timestamp:
12/15/11 15:38:09 (5 months ago)
Author:
Carsten
Message:

CaWE: In order to facilitate debugging, add a check for detecting accidental recursive re-enterings of the CommandHistoryT methods.

Location:
cafu/trunk/CaWE
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • cafu/trunk/CaWE/CommandHistory.cpp

    r364 r443  
    3030 
    3131 
     32namespace 
     33{ 
     34    class RecursionCheckerT 
     35    { 
     36        public: 
     37 
     38        RecursionCheckerT(bool& IsActive) : m_IsActive(IsActive) { wxASSERT(!m_IsActive); m_IsActive=true; } 
     39        ~RecursionCheckerT() { m_IsActive=false; } 
     40 
     41 
     42        private: 
     43 
     44        bool& m_IsActive; 
     45    }; 
     46} 
     47 
     48 
    3249CommandHistoryT::CommandHistoryT() 
    3350    : m_CurrentIndex(-1), 
     51      m_Debug_IsActive(false), 
    3452      m_InvalidCommandID(0) 
    3553{ 
     
    8199    if (m_CurrentIndex<0) return; 
    82100    wxASSERT(m_CurrentIndex<(int)m_Commands.Size()); 
     101    RecursionCheckerT RecCheck(m_Debug_IsActive); 
    83102 
    84103    // Undo all commands from the invisible commands list and delete them. 
     
    112131    if (m_CurrentIndex+1>=int(m_Commands.Size())) return; 
    113132    wxASSERT(m_CurrentIndex<(int)m_Commands.Size()-1); 
     133    RecursionCheckerT RecCheck(m_Debug_IsActive); 
    114134 
    115135    // Undo all commands from the invisible commands list and delete them. 
     
    141161bool CommandHistoryT::SubmitCommand(CommandT* Command) 
    142162{ 
     163    RecursionCheckerT RecCheck(m_Debug_IsActive); 
     164 
    143165    if (!Command->IsDone() && !Command->Do()) 
    144166    { 
  • cafu/trunk/CaWE/CommandHistory.hpp

    r285 r443  
    4848    ArrayT<CommandT*> m_Commands; 
    4949    ArrayT<CommandT*> m_InvisCommands;    ///< Stores all commands not visible in the history until a visible command is added to the history (then they are moved into the normal history). 
    50     int               m_CurrentIndex;     ///< The current index inside the commands array. -1 means no valid index. 
     50    int               m_CurrentIndex;     ///< The index of the last done command: all commands in <code>m_Commands[0 ... m_CurrentIndex]</code> are "done" (available for undo), any commands following them are "undone" (available for redo). If m_CurrentIndex is -1, there are no "done" commands at all. 
     51    bool              m_Debug_IsActive;   ///< In order to facilitate debugging, this member helps with detecting recursive calls to our functions. For example, when we call a commands CommandT::Undo() method, does it erroneously cause a recursive call back to SubmitCommand()? 
    5152 
    5253    /// The command id returned when there is no current command (when the current index is -1).