parent qaction in test
ClosedPublic

Authored by sebas on Sep 14 2016, 9:47 PM.

Details

Summary

My compiler doesn't seem to like this constructor, it bails out with the
following error:

/home/sebas/kf5/src/kde/workspace/kwin/autotests/integration/globalshortcuts_test.cpp:
In member function ‘void GlobalShortcutsTest::testConsumedShift()’:
/home/sebas/kf5/src/kde/workspace/kwin/autotests/integration/globalshortcuts_test.cpp:79:40:
error: no matching function for call to ‘QAction::QAction()’

QScopedPointer<QAction> action(new QAction);
                                   ^~~~~~~

Using this as first argument fixes the build on my machine.

Test Plan

screenedges test fails, others pass. (this screenedges test failure seems unrelated)

Diff Detail

Repository
R108 KWin
Branch
sebas/qactionctor
Lint
No Linters Available
Unit
No Unit Test Coverage
sebas updated this revision to Diff 6749.Sep 14 2016, 9:47 PM
sebas retitled this revision from to parent qaction in test.
sebas updated this object.
sebas edited the test plan for this revision. (Show Details)
sebas added a reviewer: graesslin.
Restricted Application added a project: KWin. · View Herald TranscriptSep 14 2016, 9:47 PM
Restricted Application added a subscriber: kwin. · View Herald Transcript
graesslin added inline comments.Sep 15 2016, 5:56 AM
autotests/integration/globalshortcuts_test.cpp
79

this doesn't make sense. Can you try whether:

new QAction()

or

new QAction(nullptr)

works? I don't like parenting for something in a scoped pointer

http://doc.qt.io/qt-5/qaction.html
"QAction(QObject *parent = nullptr)"

The statement is legal, this is either a problem in Qt (API break) or the compiler (resolving function signatures, maybe related to "explicit" or template usage)

Iow, this should compile and altering the code works around a bigger problem in your toolchain which will probably bite you otherwise.

> Which Qt version and compiler?

sebas added a comment.Sep 15 2016, 9:18 AM

My qaction.h (Qt 5.6.1) only has this one:

explicit QAction(QObject* parent);

so no "= nullptr". That means new QAction() doesn't work, new QAction(nullptr) works. Should I push the latter?

graesslin accepted this revision.Sep 15 2016, 10:37 AM
graesslin edited edge metadata.
In D2782#51891, @sebas wrote:

My qaction.h (Qt 5.6.1) only has this one:

explicit QAction(QObject* parent);

so no "= nullptr". That means new QAction() doesn't work, new QAction(nullptr) works. Should I push the latter?

uh, so they added it after 5.6. then this is rather important to be fixed. Please push the nullptr variant.

This revision is now accepted and ready to land.Sep 15 2016, 10:37 AM
sebas updated this revision to Diff 6759.Sep 15 2016, 11:59 AM
sebas edited edge metadata.
  • use nullptr, this pointer is scoped anyway
This revision was automatically updated to reflect the committed changes.