snow_zhangy Posted May 24, 2014 Share Posted May 24, 2014 If i use thread in a editor plugin, when i try to remove the plugin or reload the plugin it will crash. reproduce: 1: copy the code and save a cpp file 2: use editor plugin to load that cpp file 3: select the plugin and remove it result: engine crash. code: int threadID; string getName() { return "BUG"; } void init(string name) { threadID=thread("updateThread"); } void updateThread(){ while(1){ wait; } } void shutdown() { kill_thread(threadID); } void update(int need_reload) { } Link to comment
necris Posted May 28, 2014 Share Posted May 28, 2014 Sorry for late reply.Thanks for info. We've passed this issue to our devs. Link to comment
sebastianbah Posted May 29, 2014 Share Posted May 29, 2014 Hello, This issue fill be fixed in next SDK update. Update will be available in the coming days. Upd. Also new run_threads() function will be available.This function manually run all threads of the script so you can use it instead of kill_thread() functionHere is the sample of plugin with run_thread() function. int run; int threadID; string getName() { return "BUG"; } void init(string name) { run = 1; threadID = thread("updateThread"); log.message(__FUNC__ + ": thread id = %i\n",threadID); } void updateThread(){ while(run){ wait; engine.message("BUG update\n"); } } void shutdown() { run = 0; log.message("shutdown\n"); forloop(int i = 0; 10) { log.message("%d\n",i); run_threads(); } log.message("done\n"); /*kill_thread(threadID); log.message(__FUNC__ + ": kill thread id = %i\n",threadID);*/ } void update(int need_reload) { } Link to comment
Recommended Posts