Migrate the QtScript code to QJS classes.
Warning: untested
dfaure |
Migrate the QtScript code to QJS classes.
Warning: untested
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
src/kpac/script.cpp | ||
---|---|---|
316 | Not really. I prefer to do it that way for invokable as the value will be copied, but const ref works too. |
src/kpac/script.cpp | ||
---|---|---|
316 | So why would it be preferable to have the value be copied there? In general, one prefers to avoid copies, so what is the different motvation here? |
src/kpac/script.cpp | ||
---|---|---|
316 | Invokables can be called asynchronously (queued), if you take a reference and the isn't evaluated immediatly the reference might be invalid by the time the call is evaluated. |
src/kpac/script.cpp | ||
---|---|---|
316 | With queued signals, any const-reference arguments are passed via an internal value-copy IIRC, so references are not out-dated. |
src/kpac/script.cpp | ||
---|---|---|
316 | Sure, as I said, I only write it this way because a copy should be taken, and while Qt can work around declaring an async argument as a reference, I still consider it bad style to make that mistake. In any case the difference is basically academic when it comes reference counted Qt containers. You can save some nanoseconds on doing a reference pass when it isn't async, but I have wasted more time hunting down obscure bugs caused by using references in cross-thread methods in other frameworks, so I prefer this. Feel free to change it if you like though. As I said it is just a best practice/coding style for me, and not necessary for Qt invokables. |
src/kpac/script.cpp | ||
---|---|---|
316 | Okay, think I understood. Thanks for your answers :) |