Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
Description
Code
Adapted from the example at https://doc.qt.io/qt-6/signalsandslots.html
// counter.h #ifndef COUNTER_H #define COUNTER_H #include <QObject> class Counter : public QObject { Q_OBJECT Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged); public: Counter(QObject* parent = nullptr); int value() const { return m_value; } public slots: void setValue(int value); signals: void valueChanged(int newValue); private: int m_value = 0; }; #endif
Steps to reproduce
From the console, navigate to the folder that contains counter.h and run the following commands:
qdbuscpp2xml -A counter.h -o counter.xml qdbusxml2cpp -m -a counteradaptor -i counter.h -l Counter counter.xml
Outcomes
The tools silently generate broken code. setValue() is defined twice:
class CounterAdaptor: public QDBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "local.Counter") // ... public: // PROPERTIES Q_PROPERTY(int value READ value WRITE setValue) int value() const; void setValue(int value); public Q_SLOTS: // METHODS void setValue(int value); Q_SIGNALS: // SIGNALS void valueChanged(int newValue); };
Suggestion
Let the qdbus* tools detect such clashes and warn accordingly.