-
Notifications
You must be signed in to change notification settings - Fork 565
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 update of Undo history #3179
Conversation
The mouse may be clicked without the action written to the history. This change prevents modification of the 'load' type action in the history by the wrong data swap. That itself later may cause null objects written during history usage.
I'm trying to follow the pathology here, because it seems like this should be fixable in the update manager itself. When openshot-qt/src/classes/updates.py Lines 341 to 345 in 5e90b39
So if that call's unsafe when But that's the problem. After If we fix that, then it should be safe to call openshot-qt/src/classes/updates.py Lines 254 to 264 in 5e90b39
We could fix this in the Properties table view, but I bet that's not the only place this bug can be triggered, and the real bug seems to be in the update manager's handling of its own |
Urgh. Except, we can't do that, because all over the update manager there's code like this: openshot-qt/src/classes/updates.py Lines 332 to 339 in 5e90b39
If So, I think we need a new variable inside the update manager, instead. Rather than And then the code would be (using def delete(self, key):
""" Delete an item from the UpdateManager with an UpdateAction
(this action will then be distributed to all listeners) """
self.last_action = UpdateAction('delete', key)
if self.ignore_history:
self.pending_action = self.last_action
else:
self.redoHistory.clear()
self.actionHistory.append(self.last_action)
self.dispatch_action(self.last_action)
def apply_last_action_to_history(self, previous_value):
""" Apply the last action to the history """
if self.pending_action:
self.pending_action.set_old_values(previous_value)
self.actionHistory.append(self.pending_action)
self.pending_action = None At least, that's the way I read it. @jonoomph ? |
Whoops, one correction: Pushing to the stack should also clear def delete(self, key):
""" Delete an item from the UpdateManager with an UpdateAction
(this action will then be distributed to all listeners) """
self.last_action = UpdateAction('delete', key)
if self.ignore_history:
self.pending_action = self.last_action
else:
self.redoHistory.clear()
self.pending_action = None
self.actionHistory.append(self.last_action)
self.dispatch_action(self.last_action) |
It is funny thing that you using your own api in the wrong way. And instead of showing how it should be used right, you fixing the api itself... |
On this one there's actually a bigger issue, I've discovered: After you do Edit > Clear history, Undo is still enabled. It shouldn't be — there's nothing to Undo anymore! And it shouldn't re-enable until something gets pushed onto the history stack. My So now I have to go figure out what's wrong with the "Clear history" trigger... |
Aha. Simple really. Both |
Wow! You didn't read the current PRs list... I'm posting to space. |
Right now, this PR doesn't breaks logic of the mentioned #3187 , so it will be here until something will be merged. By fixing the api - this program fix can be omitted. |
I actually had read the list, it's just that "Fix main menu actions state (UI)" didn't immediately strike me as being an undo fix. 😉 (I hadn't yet read the contents of every pending PR.) |
Let's speed up other solutions! |
@SuslikV Actually, if you could reop... oh, you deleted the branch. Never mind. I was going to ask you to reopen, so I could merge this version. I'm reluctant to merge my own code without review, especially when it makes changes to central functionality like the update manager, so it might take a second or two for #3187 to make it in. But this fix I can merge, as it's pretty self-contained and we've both tested it. Not a problem, I'll split the commit out of #3187 into its own PR and merge. Thanks! |
This change prevents modification of the 'load' type action in the history by the wrong data swap. That itself later may cause
null
objects to be written during history usage.The issue happens if you:
The application hang happens if you:
Edit: designed to work with the Curve Editor: #3084