Skip to content

Commit 65f9210

Browse files
committed
Fix handling of protected operators
(in this case assignment operators of QEvent-derived classes in Qt6)
1 parent 2b6f1ce commit 65f9210

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

generator/shellheadergenerator.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c
222222
// always do a direct call, since we want to call the real virtual function here
223223
s << "this->";
224224
}
225+
if (fun->originalName() == "operator=") {
226+
// make it clear we don't want to call the (automatically generated)
227+
// assignment operator of the promoter
228+
s << meta_class->qualifiedCppName() << "::";
229+
}
225230
s << fun->originalName() << "(";
226231
writePromoterArgs(args, s);
227232
s << "); }" << endl;

generator/shellimplgenerator.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,13 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
304304
}
305305
}
306306
s << "(";
307-
if (scriptFunctionName.startsWith("operator>>")) {
307+
if (scriptFunctionName.startsWith("operator>>") && !fun->wasProtected()) {
308308
s << wrappedObject << " >>" << args.at(0)->argumentName();
309-
} else if (scriptFunctionName.startsWith("operator<<")) {
309+
} else if (scriptFunctionName.startsWith("operator<<") && !fun->wasProtected()) {
310310
s << wrappedObject << " <<" << args.at(0)->argumentName();
311-
} else if (scriptFunctionName.startsWith("operator[]")) {
311+
} else if (scriptFunctionName.startsWith("operator[]") && !fun->wasProtected()) {
312312
s << wrappedObject << "[" << args.at(0)->argumentName() << "]";
313-
} else if (scriptFunctionName.startsWith("operator") && args.size()==1) {
313+
} else if (scriptFunctionName.startsWith("operator") && args.size()==1 && !fun->wasProtected()) {
314314
QString op = scriptFunctionName.mid(8);
315315
s << wrappedObject << op << " " << args.at(0)->argumentName();
316316
} else {
@@ -328,7 +328,13 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
328328
s << " theWrappedObject->";
329329
}
330330
}
331-
s << fun->originalName() << "(";
331+
if (fun->wasProtected()) {
332+
// this is different e.g. for operators
333+
s << fun->name() << "(";
334+
}
335+
else {
336+
s << fun->originalName() << "(";
337+
}
332338
for (int i = 0; i < args.size(); ++i) {
333339
if (i > 0)
334340
s << ", ";

0 commit comments

Comments
 (0)