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
Fix HPX-Qt interaction in Qt example. #3051
Conversation
GUI objects must not be manipulated from threads other than the GUI thread. This rule was violated in the qt example. Now it is fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a lot!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the Qt thread detection mechanism works for any thread or just QThread. But nice catch!
examples/qt/widget.cpp
Outdated
list->addItem(txt); | ||
|
||
QGenericArgument arg("const QString&", &txt); | ||
QMetaObject::invokeMethod(this, "add_label", arg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this miss the Qt::QueuedConnection
argument to make sure that it's properly dispatched?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, Qt::ConnectionType is not specified, it thus should default to Qt::AutoConnection, which in turn should detect that you are in a different thread and use QueuedConnection.
It tested it with some "std::cout << get_thread_id() << std::endl;" calls that everything works as expected on my system.
But maybe adding the Qt::QueuedConnection argument would make the code more clear and readable.
examples/qt/widget.cpp
Outdated
// may be called from any thread, does not interact directly with GUI objects | ||
bool value = true; | ||
QGenericArgument arg("bool",&value); | ||
QMetaObject::invokeMethod(run_button, "setEnabled", arg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@andreasbuhr Please fix the remaining inspect errors: https://8914-4455628-gh.circle-artifacts.com/0/tmp/circle-artifacts.ljsPnLm/hpx_inspect_report.html |
On 12/05/2017 10:58 PM, Hartmut Kaiser wrote:
@andreasbuhr <https://github.com/andreasbuhr> Please fix the remaining
inspect errors:
https://8914-4455628-gh.circle-artifacts.com/0/tmp/circle-artifacts.ljsPnLm/hpx_inspect_report.html
When searching for coding guidelines, I found a ".clang-format" inside
of the hpx repository. However, neither clang-format-3.6 nor
clang-format-4.0 is able to parse it. clang-format-3.6 says:
YAML:23:24: error: invalid boolean
AlignAfterOpenBracket: DontAlign
^~~~~~~~~
clang-format-4.0 says:
YAML:26:23: error: unknown key 'AlignEscapedNewlines'
AlignEscapedNewlines: Right
^~~~~
How is clang-format supposed to be used?
|
@andreasbuhr yes, the .clang-format file in our repo relies on a recent version of the tool (clang 5 or better) |
I updated the code to have no more than 80 characters per line and explicitly use Qt::QueuedConnection to be more readable. |
GUI objects must not be manipulated from threads other than the GUI thread. This rule was violated in the qt example. Now it is fixed.