Hello, I'm developing application that uses GStreamer to take video from device then do processing with OpenCV and as GUI framework I use QT.

So... This app works on Linux well. But when I try to build it on Windows I got exception in QPainter constructor.

First-chance exception at 0x630373cc (QtOpenGLd4.dll) in guitool.exe: 0xC0000005: Access violation reading location 0xcdcdcdd5.
Unhandled exception at 0x630373cc (QtOpenGLd4.dll) in guitool.exe: 0xC0000005: Access violation reading location 0xcdcdcdd5.

Qt Code:
  1. QtOpenGLd4.dll!QScopedPointer<QGLFramebufferObjectPrivate,QScopedPointerDeleter<QGLFramebufferObjectPrivate> >::operator->() Line 112 + 0x3 bytes C++
  2. QtOpenGLd4.dll!QGLFBOGLPaintDevice::context() Line 376 + 0xe bytes C++
  3. QtOpenGLd4.dll!QGLPaintDevice::beginPaint() Line 86 + 0xd bytes C++
  4. QtOpenGLd4.dll!QOpenGLPaintEngine::begin(QPaintDevice * pdev) Line 1259 C++
  5. QtGuid4.dll!QPainter::begin(QPaintDevice * pd) Line 1881 + 0x1d bytes C++
  6. QtGuid4.dll!QPainter::QPainter(QPaintDevice * pd) Line 1508 C++
  7. guitool.exe!WVideo::paintGL() Line 63 + 0x10 bytes C++
  8. QtOpenGLd4.dll!QGLWidget::glDraw() Line 4627 C++
  9. QtOpenGLd4.dll!QGLWidget::paintEvent(QPaintEvent * __formal) Line 4425 C++
  10. QtGuid4.dll!QWidget::event(QEvent * event) Line 8518 C++
  11. QtOpenGLd4.dll!QGLWidget::event(QEvent * e) Line 4408 C++
  12. QtGuid4.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 4557 + 0x11 bytes C++
  13. QtGuid4.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 4522 + 0x10 bytes C++
  14. QtCored4.dll!QCoreApplication::notifyInternal(QObject * receiver, QEvent * event) Line 915 + 0x15 bytes C++
  15. QtCored4.dll!QCoreApplication::sendSpontaneousEvent(QObject * receiver, QEvent * event) Line 234 + 0x38 bytes C++
  16. QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev, const QRegion & rgn, const QPoint & offset, int flags, QPainter * sharedPainter, QWidgetBackingStore * backingStore) Line 5594 + 0xe bytes C++
  17. QtGuid4.dll!QWidgetPrivate::repaint_sys(const QRegion & rgn) Line 1659 C++
  18. QtGuid4.dll!QWidgetPrivate::syncBackingStore() Line 1890 C++
  19. QtGuid4.dll!QWidget::event(QEvent * event) Line 8665 C++
  20. QtOpenGLd4.dll!QGLWidget::event(QEvent * e) Line 4408 C++
  21. QtGuid4.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 4557 + 0x11 bytes C++
  22. QtGuid4.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 4522 + 0x10 bytes C++
  23. QtCored4.dll!QCoreApplication::notifyInternal(QObject * receiver, QEvent * event) Line 915 + 0x15 bytes C++
  24. QtCored4.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event) Line 231 + 0x39 bytes C++
  25. QtCored4.dll!QCoreApplicationPrivate::sendPostedEvents(QObject * receiver, int event_type, QThreadData * data) Line 1539 + 0xd bytes C++
  26. QtCored4.dll!qt_internal_proc(HWND__ * hwnd, unsigned int message, unsigned int wp, long lp) Line 496 + 0x10 bytes C++
  27. user32.dll!7e368734()
  28. [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
  29. user32.dll!7e368816()
  30. user32.dll!7e3689cd()
  31. user32.dll!7e368a10()
  32. QtCored4.dll!QEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 810 C++
  33. QtGuid4.dll!QGuiEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 1204 + 0x15 bytes C++
  34. QtCored4.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 150 C++
  35. QtCored4.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 204 + 0x2d bytes C++
  36. QtCored4.dll!QCoreApplication::exec() Line 1187 + 0x15 bytes C++
  37. QtGuid4.dll!QApplication::exec() Line 3819 C++
  38. guitool.exe!main(int argc, char * * argv) Line 19 + 0x6 bytes C++
  39. guitool.exe!WinMain(HINSTANCE__ * instance, HINSTANCE__ * prevInstance, char * __formal, int cmdShow) Line 131 + 0x12 bytes C++
  40. guitool.exe!__tmainCRTStartup() Line 547 + 0x2c bytes C
  41. guitool.exe!WinMainCRTStartup() Line 371 C
  42. kernel32.dll!7c817077()
To copy to clipboard, switch view to plain text mode 

this is the drawing code with GL initialization:

Qt Code:
  1. GLuint commands;
  2.  
  3. void WVideo::init(int w, int h)
  4. {
  5.  
  6. im_width = w;
  7. im_height = h;
  8.  
  9. glDeleteLists(commands, 1);
  10. if (fbo){
  11. delete fbo;
  12. }
  13. fbo = new QGLFramebufferObject(w, h);
  14.  
  15. commands = glGenLists(1);
  16. glNewList(commands, GL_COMPILE);
  17. glBegin(GL_QUADS);
  18. glTexCoord2d( 1, 1);
  19. glVertex2d( w-1, h-1);
  20. glTexCoord2d( 0, 1);
  21. glVertex2d( 0, h-1);
  22. glTexCoord2d( 0, 0);
  23. glVertex2d( 0, 0);
  24. glTexCoord2d( 1, 0);
  25. glVertex2d( w-1, 0);
  26.  
  27. glEnd();
  28. glEndList();
  29.  
  30. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  31. glMatrixMode(GL_PROJECTION);
  32. glLoadIdentity();
  33. glViewport(0, 0, w, h);
  34. glOrtho(0.0, w-1, 0.0, h, -0.01, 0.0);
  35. }
  36.  
  37. void WVideo::paintGL()
  38. {
  39. mutex.lock();
  40.  
  41. //if (!fbo) { init(800, 600); }
  42. if (!fbo) { init(704, 576); }
  43.  
  44. if (img){
  45. QPainter fbo_painter(fbo);
  46. fbo_painter.drawImage(QRect(0, 0, im_width, im_height), *img );
  47. fbo_painter.end();
  48. }
  49.  
  50. glMatrixMode(GL_MODELVIEW);
  51. glLoadIdentity();
  52. glEnable(GL_TEXTURE_2D);
  53.  
  54. glPushMatrix();
  55. glColor3d(255, 255, 255);
  56. glCallList(commands);
  57. glPopMatrix();
  58. mutex.unlock();
  59. }
To copy to clipboard, switch view to plain text mode