hmm... my guess is that it has to do with QMessageBox showing it self, while you are in a paintEvent() - that maybe forces a general paintEvent() on all the applications visible widgets, resulting in a recursive call.
But that is only a guess.