-
Notifications
You must be signed in to change notification settings - Fork 270
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
Markdown: Update using known GeanyDocument when available #1064
base: master
Are you sure you want to change the base?
Conversation
For whatever reason, in some cases `document_get_current()` doesn't return a valid document when it seems like it should, so when updating the markdown preview from signals where the related GeanyDocument is available, use that instead of calling `document_get_current()`. In other cases, continue to use `document_get_current()` as before. Closes geany#1062
Do you have any further information about when/why/how |
I do not, I just noticed that it was giving invalid/NULL and that I had a valid document pointer already available. Probably one of the callbacks the plugin uses gets triggered early before the document list is fully initialized or something, but I didn't spend much time trying to understand it. |
It can definitely return NULL for lots of reasons, but if it returns a pointer it should be valid since it tests it and returns NULL if not valid. |
@@ -192,7 +193,7 @@ static gboolean on_editor_notify(GObject *obj, GeanyEditor *editor, | |||
SCNotification *notif, MarkdownViewer *viewer) | |||
{ | |||
if (IS_MOD_NOTIF(notif)) { | |||
update_markdown_viewer(viewer); | |||
update_markdown_viewer(viewer, NULL); |
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.
update_markdown_viewer(viewer, NULL); | |
update_markdown_viewer(viewer, editor->document); |
What your change suggests to me is that you'd encounter cases where I'm sympathetic to the base idea of using the document for which the signal was fired though. But it really seems like it should be strictly equal to |
{ | ||
GeanyDocument *doc = document_get_current(); | ||
if (!DOC_VALID(doc)) |
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.
Wouldn't simply doc == NULL
work here? Do you really get non-NULL doc pointers that have doc->valid == FALSE
?
For whatever reason, in some cases
document_get_current()
doesn'treturn a valid document when it seems like it should, so when updating
the markdown preview from signals where the related GeanyDocument
is available, use that instead of calling
document_get_current()
.In other cases, continue to use
document_get_current()
as before.Closes #1062