Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Create ThreadView to track threads in a room #825
base: dev
Are you sure you want to change the base?
Create ThreadView to track threads in a room #825
Changes from 1 commit
3f5914f
f7b965d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
rme->id()
is exactly the same asevent->id()
in the enclosingif
. You either have to remove the enclosingif
(which is perfectly fine, I think?), or you don't need to special-case pending events here because they won't reach this code.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.
Why
std::unique_ptr
and notThread
itself? I don't see polymorphism being involved, and I'm not sure what other reasons might require dynamic allocation of a structure the size of 4 pointers.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 currently the Thread object is not copy assignable by design so this makes erasing impossible. Maybe however this is just a sign that
std::vector
is not the right containerThere 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.
No copy assignability should not be a problem for
std::vector
, it can deal with move-only objects.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.
Ah, I see it now: there's a
const
field there, which prevents it from being move assignable, and that's a problem forstd::vector::erase()
. I might look at pulling that field out ofThread
and making_threads
a hash-map.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.
After quickly playing around with code - so far it looks like you can make
ThreadView
simply aQHash<QString, Thread>
and implement all the logic you have inThreadView
insideRoom::Private::updateThread()
.Thread
can be a simplestruct
(Q_GADGET
?). That won't look quite nice when you expose threads outside ofRoom
; but if you really need to add the thread root id you can have a separate plain structure for that (possibly but not necessarily derived fromThread
). In fact, the library already has a similar case withFileTransferInfo
andFileTransferPrivateInfo
structures.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.
This is what I ended up with after playing with the code, for what it's worth. This is the meat of
Room::Private::updateThread()
, assuming thatthreads
is nowQHash<QString, Thread>
(potentially aliased asThreadView
for API convenience),Thread
is a plainstruct
with public fields, and that pending events are admitted in the thread (which is not happening yet, asdoSendEvent()
doesn't update threads).I can see that most of this code can be pulled away to
Thread::addEvent()
again, with necessary datapoints fromRoom
passed as parameters but I'll leave it at that. My main point is that you don't really needThreadView
as a separate class (so far, at least) - once you have found a thread by its root id, the rest is internal to the thread class.