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
Delete selected tables as DataItem action #8507
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fa06246
pass items to delete layer activity
signedav be0ce0c
do not pass item as argument
signedav 7acd83f
delete selected layers on spatialite and pg
signedav 9dd96da
remove unused comments
signedav f06bb79
delete/truncate selected tables for mssql-tables
signedav a1ea0ac
action deleteLayer in the dataitemproviders
signedav 4296c77
remove unused variable
signedav 1136aab
delete layer action only on items that have capability "delete"
signedav d453006
find index of layeritem with the passed uri
signedav 81faf95
use uri to get layeritem to delete
signedav 5a75195
fix - removes layers from project if they exist there
signedav 0373fe7
autogenerated sip in file
signedav 666f959
Merge branch 'master' into basicfix
signedav 37eec19
put message in log instead of message box
signedav File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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 likely to result in crashes, because after the first table is deleted providers may (and usually will) trigger a refresh of their parent. This happens in a background thread, and may result in items within the selectedDeletableItems list being deleted before deleteLayers has had a chance to handle them. I think what should be done here is that selectedDeletableItems will need to be a string list, storing the paths of the selected items instead of the items themselves. (I've experienced this crash myself when deleting OGR items, which was why the OGR provider was adapted to use a static deleteLayer method with strings instead of the layer item).
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.
And my apologies, I should have picked this up in the earlier review. That's my fault.
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.
Hm... Good point.
Can't we just check, if the item is still valid before we call to delete it?
If I understand you correctly, it means, that it shouldn't be implemented in the specific layer items and have a general
deleteItemAccordingUri( item-uri, item-type )
function inqgsinbuiltdataitemproviders
?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'm not sure I can follow this logic @nyalldawson
Does this mean, a background thread deletes items from the UI? If yes, this sounds like a guarantee for crashes and should be fixed directly instead of working around potential issues here.
Instead they should be deleted (via queued connection) on the main thread, in which case they will be deleted after this code has been executed (because this code is triggered by the UI on the main thread and executed via direct connection unless I'm mistaken).
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 believe this is already the case
Ideally yes, but in practice there must be some processEvents calls or something messing things up, because I definitely got easily reproducible crashes when this approach was used in the OGR provider.
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.
Is there a stacktrace around for this or instructions how to reproduce this?
To be honest, I'm not a big fan of implementing workarounds for badly designed code without seeing it first and having a good ground to decide that fixing the broken code is (much) harder than implementing the workaround. :/
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.
It's 7ad1d29 -- and that commit gives more clues, because it's while the confirmation dialog is shown (main thread) that the main thread event loop is running and deleting the items due to the previously queued refresh.
So that's all good -- no nasty bugs in master which we're hiding. But this PR also has messageboxes showing while deleting layers (confirmation for each layer, failure warning) and so needs to handle that same case. Approaches would be encapsulating the layer parameters from all items in advance and only using these during the delete, OR