[Github-comments] [geany/geany] FIX: filebrowser plugin: the first rightclick not working with some items on popup: (#2161)

Matthew Brush notifications at xxxxx
Thu May 23 01:20:28 UTC 2019


codebrainz commented on this pull request.



> @@ -736,13 +739,9 @@ static gboolean on_button_press(GtkWidget *widget, GdkEventButton *event, gpoint
 	}
 	else if (event->button == 3)
 	{
-		static GtkWidget *popup_menu = NULL;

One of the meanings in C of `static` is that it's only initialized once for the whole runtime, so the above code initializes `popup_menu` to `NULL` for the only/one-time initialization. Then the `if (popup_menu == NULL)` branch says "if this is the first time through this code, assign `popup_menu` with some runtime value and then never enter this branch again." It's not terribly good code, IMO, but it isn't wrong either.

> I have to revert this?

I'm not strictly opposed to the change, it just looks completely unrelated to the pull request and an argument could be made that if it's only used in one place, and it's going to leak memory anyway, then having the variable definition closer to the use of it is best.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/2161#discussion_r286744569
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20190522/aa969c20/attachment.html>


More information about the Github-comments mailing list