From b2d9205796eef23fd5d9a436d438fa2ca31ec21a Mon Sep 17 00:00:00 2001 From: sapier Date: Thu, 14 Nov 2013 18:30:43 +0100 Subject: Fix Result of processed Request was written to invalid (non existent) ResultQueue if requesting thread timed out before --- src/shader.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/shader.cpp') diff --git a/src/shader.cpp b/src/shader.cpp index 122cbea19..4bf10ce31 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -417,29 +417,31 @@ u32 ShaderSource::getShaderId(const std::string &name) if(get_current_thread_id() == m_main_thread){ return getShaderIdDirect(name); } else { - infostream<<"getShaderId(): Queued: name=\""< result_queue; + + static ResultQueue result_queue; // Throw a request in m_get_shader_queue.add(name, 0, 0, &result_queue); - infostream<<"Waiting for shader from main thread, name=\"" - < + while(true) { + // Wait result for a second + GetResult result = result_queue.pop_front(1000); - // Check that at least something worked OK - assert(result.key == name); - - return result.item; + if (result.key == name) { + return result.item; + } + } } catch(ItemNotFoundException &e){ - infostream<<"Waiting for shader timed out."< request = m_get_shader_queue.pop(); - /*infostream<<"ShaderSource::processQueue(): " + /**errorstream<<"ShaderSource::processQueue(): " <<"got shader request with " <<"name=\""<onSetConstants(services, is_highlevel); } } - + ShaderInfo generate_shader(std::string name, IrrlichtDevice *device, video::IShaderConstantSetCallBack *callback, SourceShaderCache *sourcecache) -- cgit v1.2.3