Sfoglia il codice sorgente

#IQRV #comment fix resourcewatcher lost problem

陈良瑜80374463 1 anno fa
parent
commit
77f524aa88
1 ha cambiato i file con 33 aggiunte e 0 eliminazioni
  1. 33 0
      Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp

+ 33 - 0
Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp

@@ -2770,8 +2770,41 @@ void ResourceWatcherEntity::FetchSystemSnapshot(
     }
 }
 
+#if defined(RVC_OS_WIN)
+
 SP_BEGIN_ENTITY_MAP()
 SP_ENTITY(ResourceWatcherEntity)
 SP_END_ENTITY_MAP()
 
+#else
+ResourceWatcherEntity cur;
+class SpEntityModuleStub : public ModuleBase
+{
+public:
+    SpEntityModuleStub()
+    {
+
+        try {
+            //ResourceWatcherEntity* cur = new ResourceWatcherEntity();
+            // 内存分配成功
+            m_pEntityArray[m_nEntityCount++] = dynamic_cast<CEntityBase*>(&cur);
+        }
+        catch (const std::bad_alloc& e) {
+            // 内存分配失败,捕获异常
+            Dbg("ResourceWatcher Error: Memory allocation failed for ResourceWatcherEntity.  %s", e.what());
+            // 处理错误
+        }
+        catch (...) {
+            Dbg("ResourceWatcher Error: other for ResourceWatcherEntity");
+        }
+        Dbg("ResourceWatcher SpEntityModuleStub end");
+    }
+};
+SpEntityModuleStub g_ModuleInst;
+extern "C" void __attribute__((constructor)) SoMain() {
+    g_ModuleInst.DllMain(NULL, DLL_PROCESS_ATTACH, NULL);
+}
+
+#endif
+