-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
TagsEdit code improvements and crash fix #11346
base: develop
Are you sure you want to change the base?
TagsEdit code improvements and crash fix #11346
Conversation
I've attempted to do some basic refactoring of the class. I've moved responsibility for keeping track of the current item, as well as maintaining the invariant into a dedicated "TagManager" class. This class avoids the index-tracking issues by using a QLinkedList rather than a QList, that we way never invalidate any iterators. I've further attempted to have a clear split in responsibility between I've further fixed a few minor bugs in the implementation:
There is still a bug with rendering - the height hint of the textbox is wrong on first render - and a bit of cleanup needs to be done. I'd however like to get feedback on the general approach before polishing. Another open question is the behavior of typing ";", which currently finishes editing the current tag. I think it's a bit unintuitive that this always finishes the current tag, regardless of cursor position. I'd expect the tag to be split if I type ";" in the middle of a tag. What do you think? Any idea why the initial height hint may be off? |
Thank you for this work! I do agree that typing a ; or , should cause the tags to be split instead of ending typing immediately. But what about pressing space, that also ends tag typing. That could also help with pasting tag strings. |
4016df4
to
19b60bd
Compare
@libklein sorry just coming back to this. I made a bunch of code improvements to align with our standards. Also noticed that now the tags view when editing an entry gets cut off when first shown: The view expands vertically when focused to not be cut off. Not sure where in the list of changes this happened. |
c09cea8
to
a2c1f7a
Compare
|
@michaelk83 those are not the causes. I put a bunch of time into diagnosing this and we were basically fighting Qt for sizing. I have a WIP commit added that improves the situation substantially and allows for external styling of the tags display instead of overriding everything internally.
|
Fix crash when pressing home on empty tag field Move completer to TagsEdit. Move cursor blink status to TagsEdit. Move paint implementation to impl. Simplify calcRect and drawTag. Hide editing_index and cursor position. Fix bug where an empty tag was shown if the tag edit was unfocused. Fix a bug where the scollbar was not updated when a tag was removed. Hide remaining TextEdit internal fields. Refactor to use QLinkedList. Remove obsolete EmptyTagIterator. Encapsulate tags and selected index in tags manager.
9f0dee3
to
efd4f08
Compare
TODO:
|
efd4f08
to
e7553ea
Compare
Fix bug where pressing home on empty tag field crashes the program.
Bug is caused by https://github.com/libklein/keepassxc/blob/develop/src/gui/tag/TagsEdit.cpp#L340. The
currentText().isEmpty()
allows to invalidate the invariant if the current (and only) tag is empty. In this case, tags is resized to 0 (the only tag is erased) and the program crashes ascurrentText()
accessed in https://github.com/libklein/keepassxc/blob/develop/src/gui/tag/TagsEdit.cpp#L504 fails as the tags list is now empty (https://github.com/libklein/keepassxc/blob/develop/src/gui/tag/TagsEdit.cpp#L387).Fixes: #11344