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

fix remaining app crasher bugs #890

Merged
merged 7 commits into from Mar 10, 2020
Merged

Conversation

redshiftzero
Copy link
Contributor

@redshiftzero redshiftzero commented Mar 7, 2020

Description

Similar fix to #887 but for the remaining crasher bugs

Fixes #859
Fixes #857

Test Plan

  1. Start dev server
  2. Run client with debug-level logs: LOGLEVEL=DEBUG ./run.sh
  3. Click on a source (this creates its SourceConversationWrapper).
  4. Delete the source locally, see that the SourceConversationWrapper was deleted:
2020-03-09 17:58:59,541 - securedrop_client.storage:61(delete_local_source_by_uuid) INFO: Deleted source with UUID c84874c7-cf7c-4d66-9fdb-c98334a4de07 from local database.
2020-03-09 17:58:59,598 - securedrop_client.gui.widgets:729(delete_source) DEBUG: Deleting SourceConversationWrapper for c84874c7-cf7c-4d66-9fdb-c98334a4de07
  1. Use the JI to delete a source that you haven't clicked on yet in the client. Wait for a sync. See that you see the following:
2020-03-09 18:00:39,426 - securedrop_client.gui.widgets:729(delete_source) DEBUG: Deleting SourceConversationWrapper for 6985ed05-c77d-4120-90ff-4af8fa737882
2020-03-09 18:00:39,426 - securedrop_client.gui.widgets:734(delete_source) DEBUG: No SourceConversationWrapper for 6985ed05-c77d-4120-90ff-4af8fa737882 to delete
  1. Now click on a third source in the client.
  2. Use the JI to delete that third source. Wait for a sync. See that you see the following:
2020-03-09 18:02:47,263 - securedrop_client.gui.widgets:729(delete_source) DEBUG: Deleting SourceConversationWrapper for 070fbe2a-7fc8-4350-87c7-7450728888a7

Checklist

If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:

  • I have tested these changes in the appropriate Qubes environment
  • I do not have an appropriate Qubes OS workstation set up (the reviewer will need to test these changes)
  • These changes should not need testing in Qubes

If these changes add or remove files other than client code, packaging logic (e.g., the AppArmor profile) may need to be updated. Please check as applicable:

  • I have submitted a separate PR to the packaging repo
  • No update to the packaging logic (e.g., AppArmor profile) is required for these changes
  • I don't know and would appreciate guidance

@sssoleileraaa
Copy link
Contributor

sssoleileraaa commented Mar 9, 2020

this might also fix #899 and #896

@redshiftzero redshiftzero changed the title [wip] fix remaining app crasher bugs fix remaining app crasher bugs Mar 9, 2020
@redshiftzero redshiftzero marked this pull request as ready for review March 9, 2020 23:36
We have a loop at the end of ConversationView.update() that removes
widgets from the conversation view that are associated with
an item that is no longer in the source collection. We should also
ensure that we remove python references to these widgets from the
current_messages dict.
And remove its reference in the dict we store on the MainView
Since we call update_sources() in both the source-deleted-due-to-sync
and source-deleted-due-to-source-deletion-job-completion scenarios, we
can put the logic to remove the corresponding SourceConversationWrapper
in one place.
logger.debug('Deleting SourceConversationWrapper for {}'.format(source_uuid))
conversation_wrapper = self.source_conversations[source_uuid]
conversation_wrapper.deleteLater()
self.source_conversations.pop(source_uuid)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you can just use del if you don't need the return value

@@ -692,7 +692,10 @@ def show_sources(self, sources: List[Source]):
self.empty_conversation_view.show_no_source_selected_message()
self.empty_conversation_view.show()

self.source_list.update(sources)
deleted_sources = self.source_list.update(sources)
for source_uuid in deleted_sources:
Copy link
Contributor

Choose a reason for hiding this comment

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

this change makes a lot of sense to me, before we would delete the source items without deleting the conversation wrappers

@@ -1896,6 +1921,7 @@ def __init__(

self.controller = controller
self.file = self.controller.get_file(file_uuid)
self.uuid = file_uuid
Copy link
Contributor

Choose a reason for hiding this comment

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

can we remove self.file since we keep its uuid now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unfortunately we still need this as the initializer calls _set_file_state which uses self.file

for item_widget in current_conversation.values():
self.current_messages.pop(item_widget.uuid)
Copy link
Contributor

Choose a reason for hiding this comment

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

since we already have a source dict and a conversation wrapper dict, why do we need a current_messages dict?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they each serve different purposes on different widgets: one is on the source list mapping individual sources to their SourceWidget in the source list, one is on the main view mapping individual sources to SourceConversationWrapper parent widgets, and this one on the conversation view which maps message/file/reply items to their corresponding widget.

This dict serves the purpose of on a per-source basis tracking which widgets are displayed: when we draw the view, we only draw items that aren't already in the dict.

Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

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

i reviewed the code and it lgtm, i also tested the hell out of this for n=100 or less and i didn't see any crashes. test plan is good.

@sssoleileraaa sssoleileraaa merged commit 7f642e0 into master Mar 10, 2020
@sssoleileraaa sssoleileraaa deleted the 857-conversation-view-ref branch March 10, 2020 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants