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

Fix HPX-Qt interaction in Qt example. #3051

Merged
merged 2 commits into from Dec 13, 2017

Conversation

andreasbuhr
Copy link
Contributor

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.

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.
Copy link
Member

@hkaiser hkaiser left a 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!

Copy link
Member

@sithhell sithhell left a 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!

list->addItem(txt);

QGenericArgument arg("const QString&", &txt);
QMetaObject::invokeMethod(this, "add_label", arg);
Copy link
Member

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?

Copy link
Contributor Author

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.

// 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@hkaiser
Copy link
Member

hkaiser commented Dec 5, 2017

@andreasbuhr
Copy link
Contributor Author

andreasbuhr commented Dec 6, 2017 via email

@hkaiser
Copy link
Member

hkaiser commented Dec 6, 2017

@andreasbuhr yes, the .clang-format file in our repo relies on a recent version of the tool (clang 5 or better)

@andreasbuhr
Copy link
Contributor Author

I updated the code to have no more than 80 characters per line and explicitly use Qt::QueuedConnection to be more readable.

@msimberg msimberg merged commit 60feca7 into STEllAR-GROUP:master Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants