diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2020-02-24 20:06:45 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2020-02-26 20:50:18 +0100 |
commit | e1920f65936fe7d712441e88c023746ab5c21cee (patch) | |
tree | 9b5a6897b50e0a7b9ec1e5b5d50a9f79238d50ed /src | |
parent | f949f336888c7205d06b56073805e201246fae9c (diff) |
QShortcut: fix ambiguity with new PMF ctors
The new PMF ctors introduced with a4751f8824723acaee4b9d8aa78a59c2aa36cb3e
created some ambiguities with existing old-style connects. Fix it by
explitly checking if the given pointers are pointers from QObject
derived classes.
Fixes: QTBUG-82415
Change-Id: I70d51a6d50384fe6b5083fa3b94492ab6ed97086
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/kernel/qshortcut.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h index 4f9c5ba0f7..384f1967c9 100644 --- a/src/widgets/kernel/qshortcut.h +++ b/src/widgets/kernel/qshortcut.h @@ -95,7 +95,8 @@ public: template<class Obj1, typename Func1> QShortcut(const QKeySequence &key, QWidget *parent, const Obj1 *object1, Func1 slot1, - Qt::ShortcutContext context = Qt::WindowShortcut) + Qt::ShortcutContext context = Qt::WindowShortcut, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0) : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) { connect(this, &QShortcut::activated, object1, std::move(slot1)); @@ -103,7 +104,8 @@ public: template<class Obj1, typename Func1, typename Func2> QShortcut(const QKeySequence &key, QWidget *parent, const Obj1 *object1, Func1 slot1, Func2 slot2, - Qt::ShortcutContext context = Qt::WindowShortcut) + Qt::ShortcutContext context = Qt::WindowShortcut, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0) : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) { connect(this, &QShortcut::activated, object1, std::move(slot1)); @@ -113,7 +115,9 @@ public: QShortcut(const QKeySequence &key, QWidget *parent, const Obj1 *object1, Func1 slot1, const Obj2 *object2, Func2 slot2, - Qt::ShortcutContext context = Qt::WindowShortcut) + Qt::ShortcutContext context = Qt::WindowShortcut, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj2*>::Value>::type* = 0) : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) { connect(this, &QShortcut::activated, object1, std::move(slot1)); |