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

Save task before closing editor #1175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SqAtx
Copy link
Contributor

@SqAtx SqAtx commented Jan 20, 2025

Fixes #1138

When the task editor gets closed, it first calls
self.textview.process() which, after processing, calls self.save_cb(), which is set to TaskEditor.light_save(). This only calls TaskEditor.save() at most every 7 seconds. So if you crete a new task and close its editor within 7 seconds, the task doesn't get saved.

This commit makes TaskEditor.desctruction() call TaskEditor.save(), to make sure the task is saved properly before closing the task popup.

Fixes getting-things-gnome#1138

When the task editor gets closed, it first calls
`self.textview.process()` which, after processing, calls
`self.save_cb()`, which is set to `TaskEditor.light_save()`. This only
calls `TaskEditor.save()` at most every 7 seconds. So if you crete a new
task and close its editor within 7 seconds, the task doesn't get saved.

This commit makes `TaskEditor.desctruction()` call `TaskEditor.save()`,
to make sure the task is saved properly before closing the task popup.
Copy link
Contributor Author

@SqAtx SqAtx left a comment

Choose a reason for hiding this comment

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

I'd love to start adding tests for this type of thing, but we don't currently have tests for GTK components, so it's going to take some time to learn how and start writing them.

# self.pengine.onTaskClose(self.plugin_api)
# self.pengine.remove_api(self.plugin_api)

tid = self.task.id

if self.is_new():
if self.task.is_new():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

    def is_new(self) -> bool:
        return self.task.is_new()

I wouldn't mind getting rid of that method eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New tasks sometimes don't get saved
1 participant