Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Qt6 - Fix issue with QItemSelectionModel::select method in Mu #685

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions src/lib/mu/MuQt6/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,37 @@ namespace Mu
return Q_ARG(int, 0);
}

QMetaMethodArgument argument(STLVector<Pointer>::Type& gcCache,
QMetaMethod& method, const Type* T, Value& v,
QString& s, QVariant& qv)
{
// Special case for QItemSelectionModel::select method.
if (method.name().toStdString() == "select")
{
int parametersCount = method.parameterCount();
if (parametersCount > 0)
{
for (int i = 0; i < parametersCount; i++)
{
std::string tName = T->name().c_str();
// Check if the parameter is a
// QItemSelectionModel::SelectionFlags and passed as int.
if (method.parameterTypeName(i).toStdString()
== "QItemSelectionModel::SelectionFlags"
&& tName == "int")
{
QItemSelectionModel::SelectionFlags flags =
QItemSelectionModel::SelectionFlags(v._int);
return Q_ARG(QItemSelectionModel::SelectionFlags,
flags);
}
}
}
}

return argument(gcCache, T, v, s, qv);
}

static NODE_IMPLEMENTATION(invokeMethod0, void)
{
if (QObject* o = object<QObject>(NODE_ARG_OBJECT(0, ClassInstance)))
Expand Down Expand Up @@ -972,10 +1003,10 @@ namespace Mu
QString s1, s2;
QVariant v1, v2;

bool result =
method.invoke(o, Qt::DirectConnection,
argument(gcCache, F->argType(1), p0, s1, v1),
argument(gcCache, F->argType(2), p1, s2, v2));
bool result = method.invoke(
o, Qt::DirectConnection,
argument(gcCache, method, F->argType(1), p0, s1, v1),
argument(gcCache, method, F->argType(2), p1, s2, v2));

if (!result)
{
Expand Down
4 changes: 4 additions & 0 deletions src/lib/mu/MuQt6/MuQt6/Bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ namespace Mu
const Type* T, Value& v, QString& s,
QVariant& qv);

QMetaMethodArgument argument(STLVector<Pointer>::Type& gcCache,
QMetaMethod& method, const Type* T, Value& v,
QString& s, QVariant& qv);

} // namespace Mu

#endif // __MuQt__Bridge__h__
Loading