From 5f806cfa18a48e25bd99382df2704fb67d0e0d5f Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 9 Jul 2014 13:50:27 +0200 Subject: [PATCH] Minor fixes to the Tool Framework. --- common/tool/tool_manager.cpp | 2 -- include/tool/coroutine.h | 22 +++++++++++++++------- include/tool/tool_event.h | 4 ---- include/tool/tool_manager.h | 3 --- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 4aa62d2e99..4ce84ca2ba 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -470,8 +470,6 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState ) bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent ) { -// wxLogDebug( "event: %s", aEvent.Format().c_str() ); - // Early dispatch of events destined for the TOOL_MANAGER if( !dispatchStandardEvents( aEvent ) ) return false; diff --git a/include/tool/coroutine.h b/include/tool/coroutine.h index 9daab59cb2..3385dece7d 100644 --- a/include/tool/coroutine.h +++ b/include/tool/coroutine.h @@ -56,11 +56,10 @@ template class COROUTINE { public: - COROUTINE() + COROUTINE() : + m_saved( NULL ), m_self( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize ), + m_running( false ) { - m_stackSize = c_defaultStackSize; - m_stack = NULL; - m_saved = NULL; } /** @@ -69,7 +68,8 @@ public: */ template COROUTINE( T* object, ReturnType(T::* ptr)( ArgType ) ) : - m_func( object, ptr ), m_saved( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize ) + m_func( object, ptr ), m_self( NULL ), m_saved( NULL ), m_stack( NULL ), + m_stackSize( c_defaultStackSize ), m_running( false ) { } @@ -78,8 +78,10 @@ public: * Creates a coroutine from a delegate object */ COROUTINE( DELEGATE aEntry ) : - m_func( aEntry ), m_saved( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize ) - {}; + m_func( aEntry ), m_saved( NULL ), m_self( NULL ), m_stack( NULL ), + m_stackSize( c_defaultStackSize ), m_running( false ) + { + } ~COROUTINE() { @@ -138,6 +140,12 @@ public: // align to 16 bytes void* sp = (void*) ( ( ( (ptrdiff_t) m_stack ) + m_stackSize - 0xf ) & ( ~0x0f ) ); + // correct the stack size + m_stackSize -= ( (size_t) m_stack + m_stackSize - (size_t) sp ); + + assert( m_self == NULL ); + assert( m_saved == NULL ); + m_args = &aArgs; m_self = boost::context::make_fcontext( sp, m_stackSize, callerStub ); m_saved = new boost::context::fcontext_t(); diff --git a/include/tool/tool_event.h b/include/tool/tool_event.h index bdfe8a8a10..49f8fe55f1 100644 --- a/include/tool/tool_event.h +++ b/include/tool/tool_event.h @@ -318,9 +318,6 @@ public: if( m_commandId && aEvent.m_commandId ) return *m_commandId == *aEvent.m_commandId; - - // Command-type event has to contain either id or string - assert( false ); } return true; @@ -496,7 +493,6 @@ inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEventA, const TOOL_E return l; } - inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEvent, const TOOL_EVENT_LIST& aEventList ) { diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index 6969483664..54ec87bf57 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -384,9 +384,6 @@ private: /// Flag saying if the currently processed event should be passed to other tools. bool m_passEvent; - - /// Pointer to the tool on the top of the active tools stack. - TOOL_STATE* m_currentTool; }; #endif