Bug 443415 - Signals of IProjectBuilder cannot be connected
Summary: Signals of IProjectBuilder cannot be connected
Status: RESOLVED WORKSFORME
Alias: None
Product: kdevelop
Classification: Applications
Component: general (other bugs)
Version First Reported In: 5.5.0
Platform: Other All
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-06 22:10 UTC by twollgam
Modified: 2021-11-09 21:23 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description twollgam 2021-10-06 22:10:50 UTC
The signals of IProjectBuilder cannot be connected. I think the class must be derived from QObject.

STEPS TO REPRODUCE

void TestView::built(KDevelop::ProjectBaseItem*);

void TestView::addTestSuite(ITestSuite* suite)
{
    auto builder = suite->project()->buildSystemManager()->builder();    
    connect(builder, &KDevelop::IProjectBuilder::built, this, &TestView::built);

OBSERVED RESULT

In file included from /usr/include/x86_64-linux-gnu/qt5/QtGui/qkeysequence.h:45,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qaction.h:44,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QAction:1,
                 from /home/twollgam/projects/TestBrowser/src/testview.h:3,
                 from /home/twollgam/projects/TestBrowser/src/testview.cpp:1:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs.h: In instantiation of ‘struct QtPrivate::HasQ_OBJECT_Macro<KDevelop::IProjectBuilder>’:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qobject.h:235:9:   required from ‘static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = void (KDevelop::IProjectBuilder::*)(KDevelop::ProjectBaseItem*); Func2 = void (TestView::*)(KDevelop::ProjectBaseItem*); typename QtPrivate::FunctionPointer<Func>::Object = KDevelop::IProjectBuilder; typename QtPrivate::FunctionPointer<Func2>::Object = TestView]’
/home/twollgam/projects/TestBrowser/src/testview.cpp:529:79:   required from here
/usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs.h:622:37: error: ‘qt_metacall’ is not a member of ‘KDevelop::IProjectBuilder’
  622 |         enum { Value =  sizeof(test(&Object::qt_metacall)) == sizeof(int) };
      |                                     ^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/qt5/QtGui/qtguiglobal.h:43,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qtwidgetsglobal.h:43,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qaction.h:43,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QAction:1,
                 from /home/twollgam/projects/TestBrowser/src/testview.h:3,
                 from /home/twollgam/projects/TestBrowser/src/testview.cpp:1:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qobject.h: In instantiation of ‘static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = void (KDevelop::IProjectBuilder::*)(KDevelop::ProjectBaseItem*); Func2 = void (TestView::*)(KDevelop::ProjectBaseItem*); typename QtPrivate::FunctionPointer<Func>::Object = KDevelop::IProjectBuilder; typename QtPrivate::FunctionPointer<Func2>::Object = TestView]’:
/home/twollgam/projects/TestBrowser/src/testview.cpp:529:79:   required from here
/usr/include/x86_64-linux-gnu/qt5/QtCore/qobject.h:235:9: error: static assertion failed: No Q_OBJECT in the class with the signal
  235 |         Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
      |         ^~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qwidget.h:45,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qaction.h:46,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QAction:1,
                 from /home/twollgam/projects/TestBrowser/src/testview.h:3,
                 from /home/twollgam/projects/TestBrowser/src/testview.cpp:1:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qobject.h:254:42: error: ‘staticMetaObject’ is not a member of ‘QtPrivate::FunctionPointer<void (KDevelop::IProjectBuilder::*)(KDevelop::ProjectBaseItem*)>::Object’ {aka ‘KDevelop::IProjectBuilder’}
  254 |                             type, types, &SignalType::Object::staticMetaObject);

EXPECTED RESULT

No compile errors.

ADDITIONAL INFORMATION

class KDEVPLATFORMPROJECT_EXPORT IProjectBuilder : public QObject
{
    Q_OBJECT
public:
Comment 1 Milian Wolff 2021-11-09 21:23:34 UTC
you have to use oldschool Qt4-like connections on interfaces, or a concrete ProjectBuilder instance.

The error is not in our code - is it?

                 from /home/twollgam/projects/TestBrowser/src/testview.h:3,

I'll close this issue. If you want to do something about it, we are happy to review your cleanup patches on gitlab.

Thanks!