-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add configure command to native messaging interface #103
base: master
Are you sure you want to change the base?
Conversation
Useful for benchmarking mostly
@@ -359,13 +370,21 @@ request_variant NativeMsgIface::parseJsonInput(QByteArray input) { | |||
ret.id = id; | |||
for (auto&& key : mandatoryKeysDownload) { | |||
QJsonValueRef val = data[key]; | |||
if (val.isNull()) { | |||
if (val.isNull() || val.isUndefined()) { |
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.
So... isNull()
is like key: ""
, whereas isUndefined()
is the key is not found at all?
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.
The returned QJsonValue is QJsonValue::Undefined if the key does not exist.
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.
How was it then working beforehand!?
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 have no idea, nor have I tested missing keys properly? They definitely look pretty distinct and incompatible:
inline bool isNull() const { return type() == Null; }
...
inline bool isUndefined() const { return type() == Undefined; }
(From qjsonvalue.h#107-113)
Good! I should make use of this to add automatic tests on githubCI! |
I marked it as draft because I just implemented this as a one-off for some benchmarking work. However, this functionality might be useful for other use cases as well. There should be probably be a |
Yeah, that's what I do: https://github.com/XapaJIaMnu/translateLocally/blob/master/src/settings/TranslatorSettingsDialog.cpp#L24 |
I'd say no, that would be unexpected. I like the idea that it will default to whatever you selected in the GUI, but you can reconfigure it easily if you want something specific for that session/client application. In my measurements, the Configure command is pretty much free when it is the first command issued. bergamot-translator's AsyncService does almost no work until the first translation is requested. |
Oeh note to self: it should do everything from the pointer reset line in std::async or something, because that's a blocking call that will wait for all still pending translations to finish. And that should not be blocking the event loop! And then I need to think a bit about how it should treat translation requests that come in after the Configure command. They should be queued/processed after it, and not to the service that is about to be reset (thereby delaying the reset even more). So maybe the reset() should be blocking the event loop? |
Useful for benchmarking mostly