Closes #1254.
This is not completely perfect but will do the trick to delay the parsing of tasks in the current document until the main loop has triggered the also delayed colourising of the current document which is necessary for parsing the tasks. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany-plugins/pull/1257
-- Commit Summary --
* Addons: Delay updating of tasks list until document has been colorised
-- File Changes --
M addons/src/ao_tasks.c (45)
-- Patch Links --
https://github.com/geany/geany-plugins/pull/1257.patch https://github.com/geany/geany-plugins/pull/1257.diff
@elextr commented on this pull request.
Perhaps get the doc pointer first and check valid, then link the tasks object lifetime to the doc (if it isn't already).
Otherwise get current doc in the callback, since tasks doesn't write to the doc it won't do any harm if it scans tasks for the visible doc, not the one initially requested so long as its re-scanned when it becomes visible.
The chances of the doc being deleted between the idle being scheduled and the callback is unlikely, but who knows what them plugins will do. Better not to use dangling pointers.
{
+ AoTasksUpdateTasksForDocArguments *arguments = data; + AoTasks *t = arguments->t; + GeanyDocument *doc = arguments->doc;
Needs to check valid since its an unknown period and unknown actions before it happens (isn't asynchronous fun!)
{
+ AoTasksUpdateTasksForDocArguments *arguments = data; + AoTasks *t = arguments->t;
Will the lifetime of AoTasks object guarantee its still valid (see below)
@eht16 pushed 1 commit.
d6cb2c252b314088dd1ae99bacb1a55794098c79 Add more sanity checks
@eht16 pushed 1 commit.
d975ce3f6c1a8e03d94ceb73bfc635b84bf2a1cc Add more sanity checks
@eht16 commented on this pull request.
{
+ AoTasksUpdateTasksForDocArguments *arguments = data; + AoTasks *t = arguments->t; + GeanyDocument *doc = arguments->doc;
I don't know if there is more than checking `data` for `NULL`. BUt at least I've added this.
@eht16 commented on this pull request.
{
+ AoTasksUpdateTasksForDocArguments *arguments = data; + AoTasks *t = arguments->t;
I think so. The `AoTasks` object exists as long as the Addons plugin is loaded, independently of opened documents and independent of whether the Tasks addon is enabled or not.
While in theory possible I think it's highly unlikely that a user will manage to unload the Addons plugin or even only to quit Geany so that the `AoTasks` object will be destroyed while an idle callback is still waiting to be executed.
@elextr fine by you now?
@elextr commented on this pull request.
{
+ AoTasksUpdateTasksForDocArguments *arguments = data; + AoTasks *t = arguments->t; + GeanyDocument *doc = arguments->doc;
I was thinking of DOCVALID()
@eht16 pushed 1 commit.
b1ba03c3edc70677df578ee7282456e38f965af5 Use DOC_VALID macro across the Addons plugin
@eht16 commented on this pull request.
{
+ AoTasksUpdateTasksForDocArguments *arguments = data; + AoTasks *t = arguments->t; + GeanyDocument *doc = arguments->doc;
Alright, done and also in a few more places in the Addons plugin.
I'd like to merge this in a few days if there are no objections or further remarks.
Oops, missed the changes being added, fine by me.
Merged #1257 into master.
github-comments@lists.geany.org