[ad_1]
because ue4 does not allow me to add instances and remove them from frannable so i created a class that take tasks and store the variables that it will need to process the Add or Remove Instance functions then every frame he will process this functions
NMR_Taskable is the class that store the tasks then process them
NMR_Task is pure base class have process function
NMR_Task_Add_Instance, NMR_Task_Remove_Instance two classes children from NMR_Task how there own constructor and deconstructer and process
then it do very well…
for the first like 200 to 300 (i did not calculate how many) then it crashes giving me EXCEPTION_ACCESS_VIOLATION at the line 5 of NMR_Taskable::DoTask()
if (mTasks.size() <= 0) // mTasks is std::vector<NMR_Task*>
throw 0;
Log(std::to_wstring(mTasks[0]->GetTaskNum()));
mTasks[0]->Process(); //this is virtual
delete mTasks[0];
mTasks.erase(mTasks.begin());
but after some editing i found that the problem is not from line 5, it is from line 4
and i knew that from this code
if (mTasks.size() <= 0) // mTasks is std::vector<NMR_Task>
throw 0;
Log(L"GetNum");
Log(std::to_wstring(mTasks[0]->GetTaskNum()));
Log(L"process");
mTasks[0]->Process();
Log(L"delet");
delete mTasks[0];
Log(L"Erase");
mTasks.erase(mTasks.begin());
that give me in the log file:
GetNum
Process
and it is not nullptr because NMR_Taskable::AddTask is
if (addedTask == nullptr)
throw 0;
mTasks.emplace_back(addedTask);
and it is not valid ptr because the problem wauld be from line 3 with GetTaskNum
and it is not from inside the process because it will give the eror int the Tasks.cpp file
[ad_2]