Reputation: 6677
I have an application that is receiving images from a camera. The application is written using wxWidgets and I am trying to display the image by creating a paint event. Every time I get a new image, I call Refresh on the panel.
After about a half a minute to a minute, it stops responding to the paint events. I've been looking on the wxWidgets Wiki, but I can't seem to find why it's doing that (I believe I'm allowing the GUI event loop to run).
When I change the window size, it refreshes the image as normal (so it's not blocking all paint events).
Any idea why this is happening?
I'm not sure how much this will help, but here's the paint event's code.
void ImageViewer::onPaint(wxPaintEvent &event)
{
wxBufferedPaintDC dc(this);
cv::Mat buffer;
static int count = 0;
std::cout << "drawing " << ++count << std::endl;
{
// doing stuff in a lock
}
// it doesn't ever seem to get stuck in the lock
std::cout << "finished" << std::endl;
// buffer is an object with the image data buffered
wxImage img(buffer.rows,
buffer.cols,
buffer.data, true);
wxBitmap bmp(img);
dc.DrawBitmap(bmp, 0, 0);
}
I call refresh every time I get a new image and change the buffer (changing the buffer is done inside of a lock).
Upvotes: 2
Views: 5273
Reputation: 20616
Here is something to try: call Update() immediately after your call to Refresh().
Refresh invalidates the window and queues the paint request. Update forces an immediate repaint of any invalidated rectangles.
Upvotes: 4