Bug 403578

Summary: Add warnings for QDialog::exec and similar pseudo-synchronous methods
Product: [Developer tools] clazy Reporter: smokris
Component: generalAssignee: Unassigned bugs <unassigned-bugs-null>
Status: REPORTED ---    
Severity: normal CC: smartins
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: All   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description smokris 2019-01-25 01:51:47 UTC
The documentation for QDialog::exec (http://doc.qt.io/qt-5/qdialog.html#exec) says:

> Note: Avoid using this function; instead, use open(). Unlike exec(), open()
> is asynchronous, and does not spin an additional event loop. This prevents a
> series of dangerous bugs from happening (e.g. deleting the dialog's parent
> while the dialog is open via exec()). 

There's some more explanation at https://blog.qt.io/blog/2010/02/23/unpredictable-exec/ .  Also, https://blogs.kde.org/2009/03/26/how-crash-almost-every-qtkde-application-and-how-fix-it-0 says that these methods should be avoided:

> QCoreApplication::processEvents
> QDialog::exec
> QDrag::exec
> QEventLoop::processEvents
> QProcess::waitForStarted
> QProcess::waitForFinished

It would be handy to have clazy emit warnings for calls to these methods.