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

Added common class for all qt objects #2018

Merged
merged 2 commits into from
Jul 28, 2021
Merged

Added common class for all qt objects #2018

merged 2 commits into from
Jul 28, 2021

Conversation

mguludag
Copy link
Contributor

Removed separate class layout for qt_sinks and also send logs to any custom qt (QObject) classes (QML, QFile, custom Widget etc.)

Removed separate class for qt_sinks and also send logs to any custom qt (QObject) classes (QML, QFile, custom Widget etc.)
if (textedit != nullptr) {
qtextedit_ = textedit;
qt_sink(QObject *qt_object = nullptr, const std::string &meta_method = "") {
if (qt_object != nullptr) {
Copy link
Owner

Choose a reason for hiding this comment

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

i dont understand why to allow default nullptr in ctor if it get thrown afgerward if nullptr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it doesn't matter(nullptr or qobject*) in last solution 🤔

Copy link
Owner

Choose a reason for hiding this comment

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

why not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think pass nullptr into QMetaObject::invokemethod function is valid but does nothing with nullptr. But with a valid QObject* object it will invoke a function named in meta_method string.

meta_method_ = "append";
else if (std::is_same<T, QPlainTextEdit>::value)
meta_method_ = "appendPlainText";
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method_);
Copy link
Owner

Choose a reason for hiding this comment

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

T is known at compile time, so template specialization should be used instead of the if statements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will convert solution with template specialization

…bject

Added factory funtion overloads for QTextEdit, QPlainTextEdit and QObject objects
cleaned qt_sink ctor
Copy link
Contributor Author

@mguludag mguludag left a comment

Choose a reason for hiding this comment

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

Cleaned qt_sink ctor from unnecessary nullptr checks and added factory function overloads

@gabime gabime merged commit 243c4be into gabime:v1.x Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants