Hello,

any objections to installing the attached patch?
The static_cast in Thread::getCurrent() is actually wrong if the current thread is an ExternalThread. There is some (low IMHO) potential to break applications, but doing the illegal cast is probably worse long term.

Comments?

        Cheers,
                Carsten
diff --git a/Source/Base/FieldContainer/Base/OSGThread.h b/Source/Base/FieldContainer/Base/OSGThread.h
index 92171cf..c377a25 100644
--- a/Source/Base/FieldContainer/Base/OSGThread.h
+++ b/Source/Base/FieldContainer/Base/OSGThread.h
@@ -171,6 +171,7 @@ class OSG_BASE_DLLMAPPING ThreadCommonBase : public BaseThread
   private:
 
     friend class ThreadManager;
+    friend class Thread;
 
     /*!\brief prohibit default function (move to 'public' if needed) */
     ThreadCommonBase(const ThreadCommonBase &source);
@@ -301,6 +302,8 @@ class PThreadBase : public ThreadCommonBase
 
 typedef PThreadBase ThreadBase;
 
+OSG_GEN_MEMOBJPTR(ThreadBase);
+
 #endif /* OSG_USE_PTHREADS */
 
 
@@ -387,6 +390,8 @@ class SprocBase : public ThreadCommonBase
 
 typedef SprocBase ThreadBase;
 
+OSG_GEN_MEMOBJPTR(ThreadBase);
+
 #endif /* OSG_USE_SPROC */
 
 
@@ -549,6 +554,8 @@ class WinThreadBase : public ThreadCommonBase
 
 typedef WinThreadBase ThreadBase;
 
+OSG_GEN_MEMOBJPTR(ThreadBase);
+
 #endif /* OSG_USE_WINTHREADS */
 
 
@@ -603,7 +610,7 @@ class OSG_BASE_DLLMAPPING Thread : public ThreadBase
     /*! \name                      Run                                     */
     /*! \{                                                                 */
 
-    static Thread        *getCurrent(      void              );
+    static ThreadBase    *getCurrent(      void              );
 
 
     static ObjTransitPtr  get       (const Char8     *szName,
diff --git a/Source/Base/FieldContainer/Base/OSGThread.inl b/Source/Base/FieldContainer/Base/OSGThread.inl
index 8673ff3..1b58d6f 100644
--- a/Source/Base/FieldContainer/Base/OSGThread.inl
+++ b/Source/Base/FieldContainer/Base/OSGThread.inl
@@ -339,11 +339,10 @@ BitVector Thread::getCurrentLocalFlags(void)
     return Inherited::getCurrentLocalFlags();
 }
 
-
 inline
-Thread *Thread::getCurrent(void)
+ThreadBase *Thread::getCurrent(void)
 {
-    return static_cast<Thread *>(Inherited::getCurrent());
+    return static_cast<ThreadBase *>(Inherited::getCurrent());
 }
 
 #ifdef OSG_THREAD_DEBUG_SETASPECTTO
diff --git a/Source/Contrib/ComplexSceneManager/OSGCSMDrawManager.cpp b/Source/Contrib/ComplexSceneManager/OSGCSMDrawManager.cpp
index 8edd1c7..30f190e 100644
--- a/Source/Contrib/ComplexSceneManager/OSGCSMDrawManager.cpp
+++ b/Source/Contrib/ComplexSceneManager/OSGCSMDrawManager.cpp
@@ -138,7 +138,7 @@ bool CSMDrawManager::init(void)
 
     if(_sfParallel.getValue() == true)
     {
-        _pThread   = Thread::getCurrent();
+        _pThread   = dynamic_cast<OSG::Thread *>(Thread::getCurrent());
 
 #ifdef OSG_GLOBAL_SYNC_LOCK
         _pSyncLock = Lock::get("DM::synclock", false);
------------------------------------------------------------------------------

_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core

Reply via email to