Would it even be possible to check for such a thing? moveToThread accepts a pointer to a QObject, and this pointer is passed by value. How could the function know whether this value was given to it as "QObject* pObject" or "QObject* this"? Does Qt have a way to check code before it's given to the compiler?
--- Yours sincerely, George Tasopoulos On 21 Jan 2014 09:44, "Bo Thorsen" <bthor...@ics.com> wrote: > Den 20-01-2014 17:32, Thiago Macieira skrev: > > On segunda-feira, 20 de janeiro de 2014 12:41:33, Bo Thorsen wrote: > >> I have just created a suggestion in the bug tracker to make it illegal > >> to do moveToThread(this): > >> > >> https://bugreports.qt-project.org/browse/QTBUG-36278 > >> > >> It can't be said often enough: Don't do this! But if it was illegal > >> behaviour, we wouldn't have to say it. > > > > Because it's not illegal to do it. It's just a bad idea in most cases. > > This is true, and I do see the point. If someone can actually point to a > reasonable use case for it. If not, I would still choose to make it > illegal. > > I have seen moveToThread(this) many times and every single one of them > was wrong. To me this suggests that it might be better to protect new Qt > developers instead of handing them a tool they only use to shoot > themselves in the foot with. > > > I'd rather not add a check for things you shouldn't do but that might > still > > work nonetheless. That's wasted CPU cycles for people who did the right > thing. > > This point I won't just take, though. moveToThread is not an operation > that will be used often, so optimization is almost irrelevant. Well, I > certainly hope that noone does moveToThread a lot :) > > Anyway, it's not my decision. I'll argue the case because I think it's > the right thing to do, but it's not important to me. > > Bo. > > -- > Bo Thorsen, European Engineering Manager, ICS > Integrated Computer Solutions. Delivering World-Class Applications > http://ics.com/services > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest