Fix some possible threading issues with waterfall canvas

This commit is contained in:
Charles J. Cliffe 2015-10-22 01:12:51 -04:00
parent 5fd4ba8059
commit 1e0489f974

View File

@ -72,11 +72,7 @@ void WaterfallCanvas::attachSpectrumCanvas(SpectrumCanvas *canvas_in) {
} }
void WaterfallCanvas::processInputQueue() { void WaterfallCanvas::processInputQueue() {
if (!glContext) {
return;
}
tex_update.lock(); tex_update.lock();
glContext->SetCurrent(*this);
gTimer.update(); gTimer.update();
@ -100,19 +96,19 @@ void WaterfallCanvas::processInputQueue() {
break; break;
} }
} }
waterfallPanel.update();
} }
} }
wxClientDC(this);
glContext->SetCurrent(*this);
waterfallPanel.update();
tex_update.unlock(); tex_update.unlock();
} }
void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
tex_update.lock();
wxPaintDC dc(this); wxPaintDC dc(this);
if (visualDataQueue.size() > 0) {
processInputQueue();
}
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
long double currentZoom = zoom; long double currentZoom = zoom;
@ -208,7 +204,6 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
} }
tex_update.lock();
glContext->SetCurrent(*this); glContext->SetCurrent(*this);
initGLExtensions(); initGLExtensions();
glViewport(0, 0, ClientSize.x, ClientSize.y); glViewport(0, 0, ClientSize.x, ClientSize.y);
@ -413,11 +408,9 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
} }
void WaterfallCanvas::OnIdle(wxIdleEvent &event) { void WaterfallCanvas::OnIdle(wxIdleEvent &event) {
processInputQueue();
Refresh(); Refresh();
event.RequestMore(); event.RequestMore();
if (visualDataQueue.size() > linesPerSecond) {
processInputQueue();
}
} }
void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) { void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
@ -806,6 +799,7 @@ void WaterfallCanvas::updateCenterFrequency(long long freq) {
} }
void WaterfallCanvas::setLinesPerSecond(int lps) { void WaterfallCanvas::setLinesPerSecond(int lps) {
tex_update.lock();
linesPerSecond = lps; linesPerSecond = lps;
while (!visualDataQueue.empty()) { while (!visualDataQueue.empty()) {
SpectrumVisualData *vData; SpectrumVisualData *vData;
@ -815,7 +809,7 @@ void WaterfallCanvas::setLinesPerSecond(int lps) {
vData->decRefCount(); vData->decRefCount();
} }
} }
tex_update.unlock();
} }