Results 1 to 15 of 15

Thread: paint device returned engine == 0, type: 3

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Question paint device returned engine == 0, type: 3

    What does this debugger warning means????
    Qt Code:
    1. paint device returned engine == 0, type: 3
    To copy to clipboard, switch view to plain text mode 
    And I installed 4.3.3. Are there any bugs regarding qpainter, becuase SAME CODE worked on 4.3.2.???
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: paint device returned engine == 0, type: 3

    becuase SAME CODE worked on 4.3.2.???
    Is this a warning or an error?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: paint device returned engine == 0, type: 3

    Probably because you are trying to paint on a null QPaintDevice...
    Can you post some code?

  4. #4
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: paint device returned engine == 0, type: 3

    I compiled same code under 4.3.3. and my app crashes. Then I went into debug mode with gdb and I get that warning (at runtime - after app crashes). And I do not have any clue what to do with it. I have been seeking error for 14 hours and I am desperate.
    Qt 5.3 Opensource & Creator 3.1.2

  5. #5
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: paint device returned engine == 0, type: 3

    Here is some code, I am "playing" with the code of "Cover browser demo". Here is code:
    Qt Code:
    1. void CMerchandizeBrowser::drawItemAt(QPainter *p, const QPoint &loc,
    2. const QImage &img,
    3. qint16 w, qint16 h,
    4. qint16 angle)
    5. {
    6. qDebug() << "Entered CMerchandizeBrowser::drawItemsAt ..."; // debug
    7. Q_ASSERT(p!=0);
    8. p->save();
    9. qDebug() << "After first p->save()"; // debug
    10. if (!m_MirrorCache.contains(img.cacheKey())) {
    11. QImage mirror=mirrorImage(img);
    12. m_MirrorCache.insert(img.cacheKey(), mirror);
    13. }
    14.  
    15. QPointF pt(-img.height()/2, -img.height()/2);
    16. QTransform trans;
    17. trans.scale(qreal(w)/img.width(), qreal(h)/img.height());
    18. trans.rotate(angle, Qt::YAxis);
    19. p->setTransform(trans * QTransform().translate(loc.x(), loc.y()), true);
    20.  
    21. const QImage &mirror=m_MirrorCache[img.cacheKey()];
    22. QPointF pt2(pt.x(), img.height()/2);
    23. p->save();
    24. qDebug() << "After second p->save()"; // debug
    25. Q_ASSERT(p!=0);
    26. p->setCompositionMode(QPainter::CompositionMode_Source);
    27. p->drawImage(pt2, mirror);
    28. p->restore();
    29.  
    30. p->drawImage(pt, img);
    31.  
    32. p->restore();
    33. qDebug() << "Exiting CMerchandizeBrowser::drawItemsAt ..."; // debug
    34. }
    To copy to clipboard, switch view to plain text mode 
    That warning is written only ONCE and "After first p->save()". And under 4.3.2 this exact code worked perfectly.
    Qt 5.3 Opensource & Creator 3.1.2

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: paint device returned engine == 0, type: 3

    Chill dude...
    Post some code and someone will figure it out

  7. #7
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: paint device returned engine == 0, type: 3

    On what paint device did you use the painter passed to the function before entering this function? Maybe that paint device has been deallocated.

  8. #8
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: paint device returned engine == 0, type: 3

    The warning is laucnhed after call DrawItem at from:
    Qt Code:
    1. void CMerchandizeBrowser::drawItemsBeforeSelected(QPainter *p)
    2. {
    3. qDebug() << "Entered CMerchandizeBrowser::drawItemsBeforeSelected ..."; // debug
    4. Q_ASSERT(p!=0);
    5. QPoint selPt(width()/2-m_ImagesList[m_iSelected].width()/2,
    6. height()/2-m_ImagesList[m_iSelected].height()/4);
    7. qint16 widthDiff = selPt.x();
    8. qint16 startIdx = m_iSelected - widthDiff/pos_diff;
    9.  
    10. if (startIdx < 0)
    11. startIdx = 0;
    12.  
    13. for (qint16 i = 0, idx = startIdx; idx < m_iSelected; ++i, ++idx) {
    14. const QImage &img = m_ImagesList[idx];
    15.  
    16. drawItemAt(p, QPoint(selPt.x()-(m_iSelected-i)*pos_diff, selPt.y()),
    17. img, img.width() -size_diff, img.height()-size_diff, -55);
    18. }
    19. qDebug() << "Exiting CMerchandizeBrowser::drawItemsBeforeSelected ..."; // debug
    20. }
    To copy to clipboard, switch view to plain text mode 
    Qt 5.3 Opensource & Creator 3.1.2

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: paint device returned engine == 0, type: 3

    Where is the QPainter object originally created? Where does CMerchandizeBrowser::drawItemsBeforeSelected() get called from?
    J-P Nurmi

  10. #10
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: paint device returned engine == 0, type: 3

    I think painter is created here, in line 4:
    Qt Code:
    1. void CMerchandizeBrowser::paintEvent(QPaintEvent *e)
    2. {
    3. qDebug() << "Entered CMerchandizeBrowser::paintEvent ..."; // debug
    4. QPainter p(this);
    5. p.setClipRect(e->rect());
    6. p.fillRect(rect(), Qt::black);
    7. p.setRenderHint(QPainter::Antialiasing);
    8. p.setRenderHint(QPainter::SmoothPixmapTransform);
    9. #ifdef SCALE_VIEW
    10. static qint16 diff = 0;
    11. qint16 w = width() - diff;
    12. qint16 h = height() - diff;
    13. QTransform trans;
    14. trans.translate(width()/2, height()/2);
    15. trans.scale(qreal(w)/width(), qreal(h)/height());
    16. trans.translate(-width()/2, -height()/2);
    17. p.setTransform(trans);
    18. #endif
    19. drawItemsBeforeSelected(&p);
    20. drawItemsAfterSelected(&p);
    21. drawSelectedItem(&p);
    22. #ifdef SCALE_VIEW
    23. static bool goingUp = true;
    24. if (goingUp)
    25. diff += 3;
    26. else
    27. diff -= 3;
    28. if (diff >= 200 || diff <= 0)
    29. goingUp = !goingUp;
    30. #endif
    31. if (m_iSelected>=m_ImagesList.count())
    32. m_iSelected=0;
    33. //QTimer::singleShot(1000/60, this, SLOT(update()));
    34. QTimer::singleShot(100/60, this, SLOT(update()));
    35. qDebug() << "Exiting CMerchandizeBrowser::paintEvent ..."; // debug
    36. }
    To copy to clipboard, switch view to plain text mode 
    Qt 5.3 Opensource & Creator 3.1.2

  11. #11
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: paint device returned engine == 0, type: 3

    You say the app is crashing, do you know where?
    Last edited by high_flyer; 12th December 2007 at 11:14.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  12. #12
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: paint device returned engine == 0, type: 3

    Quote Originally Posted by MarkoSan View Post
    Qt Code:
    1. void CMerchandizeBrowser::paintEvent(QPaintEvent *e)
    2. {
    3. QPainter p(this);
    4. [...]
    5. //QTimer::singleShot(1000/60, this, SLOT(update()));
    6. QTimer::singleShot(100/60, this, SLOT(update()));
    7. }
    To copy to clipboard, switch view to plain text mode 
    Creation of QPainter looks look to me. But I hope you're aware that
    • 100/60 = 1
    • 1000/60 = 16

    so you're attempting to schedule a paint event every one or every 16th millisecond. Of course, the platform won't succeed in delivering timer events at so tight interval and Qt will also optimize it a bit behind the curtains by merging pending paint events but it might still not be a wise thing to do.
    J-P Nurmi

  13. #13
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: paint device returned engine == 0, type: 3

    But this code, even with short timer, worked fine in 4.3.2. I simply do not get it. Let me try to change this timer.

    Same warning!
    Qt 5.3 Opensource & Creator 3.1.2

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: paint device returned engine == 0, type: 3

    That doesn't mean anything. I suggest you use a debugger to find out where the crash occurs instead of shooting blind.

  15. #15
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: paint device returned engine == 0, type: 3

    Ok, let me dig into debugger ... just to be sure where ...

    Oh, my god!!!!!!!!!!!!!!

    I've seen after 15 hours of debugging that extension of pictures are wrong. I had .png instead of .jpg. Now I have just one problem. Same picture is shown twice in the llne of pictures. Why is that??
    Last edited by MarkoSan; 12th December 2007 at 12:35.
    Qt 5.3 Opensource & Creator 3.1.2

Similar Threads

  1. dummy question(Error)
    By Masih in forum Qt Programming
    Replies: 12
    Last Post: 20th July 2007, 00:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.