Skip to content

Commit

Permalink
old-style-connect: Unit-test for QPointer usage
Browse files Browse the repository at this point in the history
With some versions of gcc we need to explicitely call
QPointer::data() when using the new syntax
  • Loading branch information
Sergio Martins committed Sep 16, 2015
1 parent 48281fb commit a6de888
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/old-style-connect/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <QtCore/QObject>
#include <QtCore/QTimer>
#include <QtCore/QState>

#include <QtCore/QPointer>



Expand Down Expand Up @@ -185,3 +185,11 @@ class DerivedTestingProtected : public TestingProtected
connect(this, SIGNAL(destroyed()), this, SLOT(protec()));
}
};


void testQPointer()
{
QPointer<WithNesting> p = new WithNesting();
QObject::connect(p, SIGNAL(destroyed()), p, SLOT(deleteLater())); // Warning, and when fixed should have .data() due to gcc bug
QObject::connect(p, &WithNesting::destroyed, p, &WithNesting::deleteLater);
}
1 change: 1 addition & 0 deletions tests/old-style-connect/test.expected
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ main.cpp:156:9: warning: Old Style Connect [-Wclazy-old-style-connect]
main.cpp:157:9: warning: Old Style Connect [-Wclazy-old-style-connect]
main.cpp:158:9: warning: Old Style Connect [-Wclazy-old-style-connect]
main.cpp:185:9: warning: Old Style Connect [-Wclazy-old-style-connect]
main.cpp:193:5: warning: Old Style Connect [-Wclazy-old-style-connect]
namespaces.cpp:31:5: warning: Old Style Connect [-Wclazy-old-style-connect]
namespaces.cpp:32:5: warning: Old Style Connect [-Wclazy-old-style-connect]
q_private_slot.cpp:8:9: warning: Old Style Connect [-Wclazy-old-style-connect]
Expand Down

0 comments on commit a6de888

Please sign in to comment.