Skip to content

Commit ef274c7

Browse files
committed
Fixed file.AsyncRead + Updated Test script
1 parent 84c0dfb commit ef274c7

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

_testing/gmod_testing.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ local ret, err = pcall(function()
113113
["Angle"] = Angle(10, 9, 8),
114114
["Vector"] = Vector(1, 2, 3),
115115
})
116-
117-
iFace = LuaThreaded.CreateInterface()
118-
iFace:InitGmod()
119-
iFace:RunFile("includes/init.lua")
120-
iFace:RunString(code)
121-
iFace:RunHook("ExampleHook", "ExampleArg", 1234, true, Vector(1, 2, 3), Angle(4, 5, 6))
122116

123117
local startTime = SysTime()
124118
for k=1, 100000 do
@@ -137,6 +131,12 @@ local ret, err = pcall(function()
137131
if LuaThreaded.GetValue(1000) != nil then
138132
error("LuaThreaded.SetValue failed! Investigate!")
139133
end
134+
135+
iFace = LuaThreaded.CreateInterface()
136+
iFace:InitGmod()
137+
iFace:RunFile("includes/init.lua")
138+
iFace:RunString(code)
139+
iFace:RunHook("ExampleHook", "ExampleArg", 1234, true, Vector(1, 2, 3), Angle(4, 5, 6))
140140
end)
141141

142142
if err then

source/library_file.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ void AsyncCallback(const FileAsyncRequest_t &request, int nBytesRead, FSAsyncSta
1010
{
1111
async->finished = true;
1212
async->nBytesRead = nBytesRead;
13+
async->status = err;
1314
char* content = new char[nBytesRead + 1];
1415
std::memcpy(static_cast<void*>(content), request.pData, nBytesRead);
1516
content[nBytesRead] = '\0';
@@ -58,7 +59,7 @@ void FileLibThink(ILuaThread* thread)
5859
LUA->ReferencePush(file->callback);
5960
LUA->PushString(file->req->pszFilename);
6061
LUA->PushString(file->req->pszPathID);
61-
LUA->PushNumber(file->Status);
62+
LUA->PushNumber(file->status);
6263
LUA->PushString(file->content);
6364
LUA->CallFunctionProtected(4, 0, true);
6465
LUA->ReferenceFree(file->callback);

source/lua_LuaThread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ LUA_FUNCTION(LuaThread_SetValue)
113113
{
114114
SafeDelete(it->first);
115115
SafeDelete(it->second);
116-
it = shared_table.erase(it);
116+
shared_table.erase(it);
117117
break;
118118
}
119119

source/lua_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ struct IAsyncFile
169169
ILuaThread* thread;
170170
int callback;
171171
int nBytesRead;
172-
int Status;
172+
int status;
173173
bool finished = false;
174174
const char* content;
175175
};

0 commit comments

Comments
 (0)