GNOME Bugzilla – Bug 656373
Read files provided as command line arguments
Last modified: 2012-05-08 13:48:22 UTC
Created attachment 193670 [details] [review] Fix for planner to read files/URIs from command line Planner is unable to read files from command line after introducing gtk_init_with_args() to parse command line arguments. The patch attached solves the issue and also allows to pass any URI in command line (in case a set of plugins is used).
Created attachment 193835 [details] [review] fix for the case when no files specified on command line fix for the case when no files specified on command line.
*** Bug 658569 has been marked as a duplicate of this bug. ***
I'd rather first understand how we lost this feature. It works on Planner 0.14.4 but not on master nor 0.14.5. This issue needs further investigation.
Ok, I managed to narrow it down a bit. The regression was introduced somewhere between PLANNER_0_14_4 and e8e08f5002e1842ef78fb6e0571a0cd34e40ef49. Unfortunately, I can't build commits in between those, so I'll need someone else to find bad commit.
Hello, I tested this bug using multiple commits and I've found that: in fact the last commit with this feature is: a9e57c6a8c75670fe04cfffb37ddc3d60271d5c0 planner lost this feature in commit: 8b9104f145b722dc427ea6f1216e305ad16a64e3 It is due to the call to: if "(!gtk_init_with_args (&argc, &argv," ... (line 62 in planner-main.c) and then the condition: "if (argc > 1) {" ... (line 95 in planner-main.c). Here is some debug information using planner version 0.14.5 (I see the same behavior using 8b9104f145b722dc427ea6f1216e305ad16a64e3 ): Built using: $ mkdir /tmp/test $ CC="gcc -g -O1" ./configure --prefix=/tmp/test/ make make install #/tmp/fla.planner exists and was created using planner 0.14.5 gdb --args planner /tmp/fla.planner (gdb) break 62 Breakpoint 1 at 0x41abfe: file planner-main.c, line 62. (gdb) break 95 Breakpoint 2 at 0x41ac93: file planner-main.c, line 95. (gdb) run ... Breakpoint 1, main (argc=2, argv=0x7fffffffe268) at planner-main.c:62 62 if (!gtk_init_with_args (&argc, &argv, (gdb) print argc $1 = 2 (gdb) print argv[1] $1 = 0x7fffffffe552 "/tmp/fla.planner" (gdb) n 73 filename = mrp_paths_get_image_dir ("gnome-planner.png"); (gdb) print argc $3 = 1 (gdb) print argv[1] $2 = 0x0 print args_remaining[0] $3 = (gchar *) 0x6a3d80 "/tmp/fla.planner" (gdb) continue Breakpoint 2, main (argc=1, argv=0x7fffffffe268) at planner-main.c:95 95 if (argc > 1) { ...
I see. Thank you very much for your help in finding the commit. I'm CCing Javier (since he made the change), maybe he'll want to have a look and he'll be able to repair that (or review and push the path that has been submitted here).
Created attachment 203195 [details] [review] Simple fix to 656373 in planner. Please find attached a simple patch to fix this bug. Cheers, Josué Abarca
I started reviewing this and now I get a better understanding of the problem. I prefer Maxim's approach to Josué's because, as the documentation (http://developer.gnome.org/glib/unstable/glib-Commandline-option-parser.html#G-OPTION-REMAINING:CAPS) states: > Using G_OPTION_REMAINING instead of simply scanning argv for leftover arguments has the advantage that GOption takes care of necessary encoding conversions for strings or filenames. Maxim, at first look, it seems your second patch is redoing what your first patch was undoing. Wouldn't this be cleaner if merged in one single commit?
Created attachment 209018 [details] [review] Fix for broken "open file on startup" behaviour Switch to gtk_init_with_args from GnomeProgam broke opening of files from command line and when double clicking on file in file browser. Based on patches 193670 and 193835 by Maxim Zakharov.
Attachment 209018 [details] pushed as f9840c3 - Fix for broken "open file on startup" behaviour This has been fixed and pushed to master and will be part of our next release.
*** Bug 669248 has been marked as a duplicate of this bug. ***
Alexandre & Maxim, Noticed that the fix breaks opening files with spaces in the string... Fix is to replace L1698 with "if (!mrp_project_load (priv->project, g_filename_from_uri(uri, NULL, NULL), &error)) {" ...Can provide a patch later if required.
Created new bug - added patch to : https://bugzilla.gnome.org/show_bug.cgi?id=675679