I have a QMessageBox inside a Plugin which is simply called by

msgBox = QMessageBox()
ret = msgBox.exec()

When I click the OK button there is a warning in the terminal:

Warning: QBackingStore::endPaint() called with active painter; did you forget to destroy it or call QPainter::end() on it?

After this warning algorithm works, everything is okay. However if I try multiple times to call QMessageBox and click OK the warning changes on:

Warning: QBasicTimer::stop: Failed. Possibly trying to stop from a different thread*.

In the end of the end QGIS died on signal 11[New LWP 148808]
[New LWP 148809]
[New LWP 148811]
[New LWP 148812]
[New LWP 148813]
[New LWP 148814]
[New LWP 148815]
[New LWP 148816]
[New LWP 148817]
[New LWP 148818]
[New LWP 148821]

Is there any solution?

  • Does it also throw an error when you run the code in the Python QGIS console instead of your plugin? Doing so I'm unable to reproduce your issue. Could be wrong but your issue is probably elsewhere in your plugin
    – ThomasG77
    Commented Jun 17, 2021 at 9:12
  • Yes, there is no problem in the console. Seems like I need an example of using it in plugin. Commented Jun 17, 2021 at 9:23
  • There are numerous plugins using QMessageBox without issues. The best way to confirm is to do a text search within Python plugins directory accessible via import os; dir = os.path.join(QgsApplication.qgisSettingsDirPath(), 'python', 'plugins'); QDesktopServices.openUrl(QUrl.fromLocalFile(dir))
    – ThomasG77
    Commented Jun 17, 2021 at 9:41
  • 1
    Also are you sure you don't do multithreading in your plugin? There are several posts about same kind of issue in Qt medium.com/@armin.samii/… and forum.qt.io/topic/89696/strange-errors-from-qthread
    – ThomasG77
    Commented Jun 17, 2021 at 9:44


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.