File: main.cpp

package info (click to toggle)
clazy 1.17-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 5,248 kB
  • sloc: cpp: 23,552; python: 1,450; xml: 450; sh: 237; makefile: 46
file content (107 lines) | stat: -rw-r--r-- 1,739 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <QtCore/QObject>

class MyObject;

MyObject* somefunc()
{
    return nullptr;
}

static MyObject * s_obj;

class MyObject : public QObject
{
public:
    MyObject();
    void pub();
    MyObject* memberFunc() const;
    MyObject *another;
private:
    void priv();

public slots:
    void pubSlot();

signals:
    void sig();

private Q_SLOTS:
    void privSlot();

protected:
    void prot();
    Q_SIGNAL void singularSig();
    Q_SLOT void singularSlot();
};

void MyObject::pub()
{
    emit  prot(); // Warning: emit on non slot.
    sig(); // Warning: missing emit
    prot(); // OK
    pub(); // OK
    priv(); // OK
    privSlot(); // OK
    Q_EMIT privSlot(); // Warning
    Q_EMIT somefunc()->sig(); // OK
    somefunc()->sig(); // Warning
    Q_EMIT memberFunc()->sig(); // OK
    memberFunc()->sig(); // Warning
    emit another->sig(); // OK
    emit s_obj->sig(); // OK
}


MyObject::MyObject()
{
    emit sig(); // Warning
    emit another->sig(); // OK;
    emit memberFunc()->sig(); // OK;
    [this]{ emit sig(); }; // OK
    emit singularSig(); // Warning
    singularSlot(); // OK
}

void MyObject::singularSlot()
{
    singularSig(); // Warning
}

struct NotQObject
{
    QObject *o;
    void test1() {}
    void test()
    {
        test1(); // OK
        emit test1(); // Warning
        emit o->destroyed(); // OK
    }
};

class TestBug373947 : public QObject
{
    int method()
    {
        return otherMethod(); // OK
    }

Q_SIGNALS:
    void someSignal();

public:
    int otherMethod();
};

void wrapping_syntax()
{
    MyObject obj;
    Q_EMIT(obj.sig());
    Q_EMIT((obj.sig()));
    Q_EMIT(( obj.sig() ));
    Q_EMIT(( obj.memberFunc() )); // WARN

    Q_EMIT obj.sig();
    Q_EMIT  obj.sig();
}