Skip to content

Commit 822d413

Browse files
Improve script runtime delete
1 parent 75dd00c commit 822d413

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

runtime/include/CSharpScriptRuntime.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class CSharpScriptRuntime : public alt::IScriptRuntime
2323
public:
2424
CSharpScriptRuntime(alt::ICore* server);
2525

26-
private:
26+
virtual ~CSharpScriptRuntime();
27+
28+
private:
2729
alt::ICore *core;
2830
CoreClr* coreClr;
2931
};

runtime/include/CoreClr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ class CoreClr {
121121
void** runtimeHost,
122122
const unsigned int* domainId);
123123

124-
void Shutdown(alt::ICore* server, void* runtimeHost,
125-
unsigned int domainId);
124+
/*void Shutdown(alt::ICore* server, void* runtimeHost,
125+
unsigned int domainId);*/
126126

127127
void GetPath(alt::ICore* server, const char* defaultPath);
128128

runtime/src/CSharpResourceImpl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ CSharpResourceImpl::CSharpResourceImpl(alt::ICore* server, CoreClr* coreClr, alt
197197
}
198198

199199
bool CSharpResourceImpl::Start() {
200-
alt::IResource::Impl::Start();
201200
coreClr->ExecuteManagedResource(server, this->resource->GetPath().CStr(), this->resource->GetName().CStr(), this->resource->GetMain().CStr(),
202201
this->resource);
203202
if (MainDelegate == nullptr) return false;
@@ -206,7 +205,6 @@ bool CSharpResourceImpl::Start() {
206205
}
207206

208207
bool CSharpResourceImpl::Stop() {
209-
alt::IResource::Impl::Stop();
210208
for (alt::Size i = 0, length = invokers->GetSize(); i < length; i++) {
211209
auto invoker = (*invokers)[i];
212210
delete invoker;

runtime/src/CSharpScriptRuntime.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ alt::IResource::Impl* CSharpScriptRuntime::CreateImpl(alt::IResource* resource)
1111
}
1212

1313
void CSharpScriptRuntime::DestroyImpl(alt::IResource::Impl* impl) {
14-
this->coreClr->Shutdown(this->core, ((CSharpResourceImpl*) impl)->runtimeHost,
15-
((CSharpResourceImpl*) impl)->domainId);
1614
delete impl;
1715
}
1816

1917
void CSharpScriptRuntime::OnTick() {
2018
}
19+
20+
CSharpScriptRuntime::~CSharpScriptRuntime() {
21+
delete this->coreClr;
22+
}

runtime/src/CoreClr.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ CoreClr::CoreClr(alt::ICore* server) {
9595
}
9696

9797
CoreClr::~CoreClr() {
98+
//TODO: close thread
9899
delete[] runtimeDirectory;
99100
delete[] dotnetDirectory;
101+
if (cxt != nullptr) {
102+
_closeFxr(cxt);
103+
}
100104
}
101105

102106
/*bool CoreClr::GetDelegate(alt::ICore* server, void* runtimeHost, unsigned int domainId, const char* moduleName,
@@ -303,7 +307,7 @@ int CoreClr::Execute(alt::ICore* server, alt::IResource* resource, const char* a
303307
return result;
304308
}
305309

306-
void CoreClr::Shutdown(alt::ICore* server, void* runtimeHost,
310+
/*void CoreClr::Shutdown(alt::ICore* server, void* runtimeHost,
307311
unsigned int domainId) {
308312
if (cxt != nullptr) {
309313
_closeFxr(cxt);
@@ -316,7 +320,7 @@ void CoreClr::Shutdown(alt::ICore* server, void* runtimeHost,
316320
} else {
317321
server->LogInfo(alt::String("coreclr-module: Host successfully shotted down"));
318322
}
319-
}
323+
}*/
320324

321325
void CoreClr::GetPath(alt::ICore* server, const char* defaultPath) {
322326
auto directory = opendir(defaultPath);

0 commit comments

Comments
 (0)