Sync with tizen_2.2.1
[platform/framework/native/appfw.git] / src / base / runtime / FBaseRt_Event.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 5d6c58c..4b1fbde
@@ -27,6 +27,7 @@
 #include <FBaseSysLog.h>
 #include "FBaseRt_Event.h"
 #include "FBaseRt_EventManager.h"
+#include "FBaseRt_ThreadImpl.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
@@ -130,9 +131,20 @@ _Event::AddListener(const IEventListener& listener, bool calledByCallerThread)
 
        if (calledByCallerThread)
        {
+               _ThreadImpl* pThreadImpl = _ThreadImpl::GetCurrentThreadImpl();
+               SysTryReturnResult(NID_BASE_RT, pThreadImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This is not OSP thread.");
+
+               ThreadType threadType = pThreadImpl->GetThreadType();
+               SysTryReturnResult(NID_BASE_RT, threadType != THREAD_TYPE_WORKER, E_INVALID_OPERATION, "The caller thread is not an event driven thread.");
+
+               ClearLastResult();
                _EventManager* pEventManager = _EventManager::GetCurrentEventManager();
-               SysTryReturnResult(NID_BASE_RT, pEventManager != null, E_INVALID_OPERATION
-                                                 , "The caller thread is not an event driven thread.");
+               r = GetLastResult();
+               if (IsFailed(r))
+               {
+                       SysPropagate(NID_BASE_RT, r);
+                       return r;
+               }
 
                eventManager = pEventManager->GetHandle();
        }