dlr-gtlab / intelligraph-module

A Node-based Workflow Engine for GTlab
1 stars 0 forks source link

NodeData::invoke is not portable #105

Closed rainman110 closed 1 month ago

rainman110 commented 4 months ago

In GitLab by @mariusalexander on Jun 20, 2024, 10:49

What is the current bug behavior?

On Linux (at least if using gcc) calling NodeData::invoke<T>(...) fails.

This is because of the way we instantiate QReturnArgument:

auto retarg = QReturnArgument<T>(typeid(T).name(), var);

We are using typeid(T) which sadly does not provide portable names for template types. Instead we should be calling it like this:

auto retarg = Q_RETURN_ARG(MyType, data); // MyType cannot be a template type, since the preprocessor is used here.

where Q_RETURN_ARG expands to:

Q_RETURN_ARG(type, data) QReturnArgument<type >(#type, data)

This goes nicely with the hint in Qt documentation: https://doc.qt.io/qt-5/qgenericreturnargument.html#details

I think just by luck the way we used typeid on windows with "MSVC" yields names that can be unsterstood by Qt. A quick test for double and QString yields the following names:

with MSVC

typeid(double).name() // "double"
typeid(QString).name() // "class QString"

With gcc

typeid(double).name() // "d"
typeid(QString).name() // "7QString"
rainman110 commented 4 months ago

In GitLab by @jensschmeink on Jun 20, 2024, 12:23

mentioned in commit 1255643c293c6734a60399d854eb10442482b790