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

Assorted quality of life tweaks #760

Merged
merged 10 commits into from
May 30, 2024
Merged

Assorted quality of life tweaks #760

merged 10 commits into from
May 30, 2024

Conversation

KitsuneRal
Copy link
Member

No description provided.

@KitsuneRal KitsuneRal added the enhancement A feature or change request for the library label May 19, 2024
Copy link

sonarcloud bot commented May 19, 2024

@KitsuneRal KitsuneRal marked this pull request as draft May 21, 2024 06:09
@KitsuneRal KitsuneRal force-pushed the kitsune/more-tweaks-across branch 3 times, most recently from dc98620 to ed5c1d6 Compare May 26, 2024 15:18
Mainly headers/comments/formatting/removing old cruft but also replacing
std::find_if with std::ranges::find_if in a couple of obvious places
and basing EventItem::Code enum on uint16_t instead of leaving it
to compiler mercy.
Notably: the error message about a missing specialisation is much
clearer compared to deleted dumpTo() / fillFrom().
I was surprised not to find some kind of dereferencing filter in
std::ranges, and since making custom views still doesn't quite work
as of C++23-tinted C++20 that we have for now, I made an algorithm
instead.

Curiously, GNU libstdc++ has a bug/feature where std::find[_if]()
dereferences the element in the range for your projection if (and only
if!) you use that projection is a member function pointer - acting as
findIndirect() in that particular situation.
Also: simplify the code around finalize() in quotest, as a result.
Small JSON-editing facilities for stuff you keep needing to do.

Also: move a few JSON key name constants where they belong.
In the vast vast majority of cases it should be as simple as calling
either asCBytes() or asCWritableBytes() - optionally, with the size
passed as a template parameter. They will now work on std::arrays,
FixedBuffers, QByteArrays, string literals - anything std::size() and
std::data() can be called on.
It was a pre-0.9 cleanup TODO, now closed.
I always had a mental struggle with assertion functions that print
a message: the assertion fails when the condition is false but
the message is also printed when the condition fails. Moreover,
for some reason runtime assert functions have no way of tackling stuff
in Release builds: if you want to somehow bail out in a Release build,
you have to separately check the condition and then put Q_ASSERT(false)
or its equivalent. So here's a "negative assertion" facility - it does
have footprint even in Release builds but also helps to somehow move on,
rather than just let the Release build crash on an eventual null pointer
dereferencing.
...instead of ConnectionEncryptionData, to make it easier to eventually
extend support of to-device events that have nothing with encryption
(although as of today there are pretty much no such events specced).
It wraps a rather trivial chain call to QImage::scaled() which clients
can just as well do themselves, with the parameters they deem
appropriate for _their_ purpose.
@KitsuneRal KitsuneRal marked this pull request as ready for review May 30, 2024 23:36
@KitsuneRal
Copy link
Member Author

Okay, this has been lying around for some time and doesn't seem to break anything on my machine with Quaternion at least.

@KitsuneRal KitsuneRal merged commit 57f772c into dev May 30, 2024
@KitsuneRal KitsuneRal deleted the kitsune/more-tweaks-across branch May 30, 2024 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or change request for the library
Projects
Status: 0.9 - Done
Development

Successfully merging this pull request may close these issues.

1 participant