From 5c3d447c95d55c9c7da2dd69569549992e3fd741 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Wed, 11 May 2016 10:02:48 +0200 Subject: wx: Fix driver command queue The command queue could still loose a cmd because the command was reused while still in (recursive) use, thus when deleting it after command was done a newly added command could be mistakenly deleted and not called. Root cause was that wxeFifo::Strip "deleted" to many cmds. Solve by differing deleted and executed, i.e. op= -1 cmd have been executed and op = -2 cmd have been executed and deleted. --- lib/wx/c_src/wxe_helpers.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/wx/c_src/wxe_helpers.cpp b/lib/wx/c_src/wxe_helpers.cpp index 4798e605e8..d1f607d2af 100644 --- a/lib/wx/c_src/wxe_helpers.cpp +++ b/lib/wx/c_src/wxe_helpers.cpp @@ -48,7 +48,7 @@ void wxeCommand::Delete() driver_free(buffer); buffer = NULL; } - op = -1; + op = -2; } /* **************************************************************************** @@ -84,7 +84,7 @@ wxeCommand * wxeFifo::Get() pos = m_first++; m_n--; m_first %= m_max; - } while(m_q[pos].op == -1); + } while(m_q[pos].op < 0); return &m_q[pos]; } @@ -96,7 +96,7 @@ wxeCommand * wxeFifo::Peek(unsigned int *i) return NULL; pos = (m_first+*i) % m_max; (*i)++; - } while(m_q[pos].op == -1); + } while(m_q[pos].op < 0); return &m_q[pos]; } @@ -213,7 +213,7 @@ void wxeFifo::Realloc() // Strip end of queue if ops are already taken care of, avoids reallocs void wxeFifo::Strip() { - while((m_n > 0) && (m_q[(m_first + m_n - 1)%m_max].op == -1)) { + while((m_n > 0) && (m_q[(m_first + m_n - 1)%m_max].op < -1)) { m_n--; } } -- cgit v1.2.3