Add functionality for Delete Template#4437
Add functionality for Delete Template#4437unichronic wants to merge 1 commit intomapeditor:masterfrom
Conversation
bjorn
left a comment
There was a problem hiding this comment.
Thank you for looking into this feature, @unichronic!
Currently after deleting a template it takes 10-15s to disappear from the file list during Folders refresh using
FileSystemWatcher.
Do you think that's an issue?
Yes, this is not ideal. It's rather longer than I would expect since the FileSystemWatcher sets mChangedPathsTimer.setInterval(500), meaning it should only take half a second until the list is refreshed. But I think regardless, we should remove the matching entry from the model immediately after successful removal of the file.
I've left two additional comments.
src/tiled/projectdock.cpp
Outdated
| if (inUse) break; | ||
| } | ||
|
|
||
| if (inUse) { |
There was a problem hiding this comment.
Consider making a local static isTemplateInUse function, so you can just return true instead of setting and checking an isUse variable.
src/libtiled/templatemanager.cpp
Outdated
| { | ||
| if (auto templ = mObjectTemplates.take(fileName)) { | ||
| mWatcher->removePath(fileName); | ||
| delete templ; |
There was a problem hiding this comment.
Of course, we can't actually delete the template instance when it is still in use, even if the user might be fine with this. By deleting this object, any references to this template will become roaming pointers and can cause crashes or random broken behavior later.
Currently, templates are never unloaded, which is what avoids such issues. I wonder if it hurts to just keep them in memory even if we delete the file.
yes, the Addressed the other comments. |
ref #1723
I have added the delete functionality for templates. Please check it out if the changes are alright.
Currently after deleting a template it takes 10-15s to disappear from the file list during Folders referesh using
FileSystemWatcher.Do you think that's an issue?