File indexing completed on 2024-05-05 05:41:40
0001 #include <QtCore/QThread> 0002 #include <QtCore/QMutexLocker> 0003 0004 void external(int foo); 0005 0006 class MyThread; 0007 class MyThread : public QThread 0008 { 0009 public Q_SLOTS: 0010 void slot1() {} // OK 0011 void slot2(); 0012 void slot4(); 0013 void slot5(); 0014 void slot6(); 0015 public: 0016 void slot3(); 0017 int m_foo; 0018 }; 0019 0020 void MyThread::slot2() { m_foo = 1; } // Warn 0021 0022 void MyThread::slot5() {} 0023 void MyThread::slot6() { external(m_foo); } // Warn 0024 0025 QMutex s_m; 0026 void MyThread::slot4() // OK 0027 { 0028 QMutexLocker l(&s_m); 0029 } 0030 0031 void slot3() {} 0032 0033 int main() 0034 { 0035 MyThread *m; 0036 QThread *t; 0037 QObject *o; 0038 0039 o->connect(o, &QObject::destroyed, m, &MyThread::slot1); // OK 0040 o->connect(o, &QObject::destroyed, m, &MyThread::slot3); // Warn 0041 o->connect(o, &QObject::destroyed, m, &QThread::requestInterruption); // OK 0042 o->connect(o, &QObject::destroyed, t, &QThread::requestInterruption); // OK 0043 0044 }