After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 656373 - Read files provided as command line arguments
Read files provided as command line arguments
Status: RESOLVED FIXED
Product: planner
Classification: Other
Component: General
0.14.x
Other Linux
: High major
: ---
Assigned To: Alexandre Franke
planner-maint
: 658569 669248 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-08-12 02:45 UTC by Maxim Zakharov
Modified: 2012-05-08 13:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix for planner to read files/URIs from command line (3.70 KB, patch)
2011-08-12 02:45 UTC, Maxim Zakharov
none Details | Review
fix for the case when no files specified on command line (2.18 KB, patch)
2011-08-15 00:24 UTC, Maxim Zakharov
none Details | Review
Simple fix to 656373 in planner. (738 bytes, patch)
2011-12-10 22:58 UTC, jmaslibre
rejected Details | Review
Fix for broken "open file on startup" behaviour (3.51 KB, patch)
2012-03-05 17:30 UTC, Alexandre Franke
committed Details | Review

Description Maxim Zakharov 2011-08-12 02:45:33 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).
Comment 1 Maxim Zakharov 2011-08-15 00:24:34 UTC
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.
Comment 2 Alexandre Franke 2011-09-08 14:27:51 UTC
*** Bug 658569 has been marked as a duplicate of this bug. ***
Comment 3 Alexandre Franke 2011-09-08 14:48:02 UTC
*** Bug 658569 has been marked as a duplicate of this bug. ***
Comment 4 Alexandre Franke 2011-09-29 13:33:29 UTC
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.
Comment 5 Alexandre Franke 2011-09-29 14:27:43 UTC
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.
Comment 6 jmaslibre 2011-12-05 05:59:57 UTC
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) {
    ...
Comment 7 Alexandre Franke 2011-12-05 14:08:45 UTC
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).
Comment 8 jmaslibre 2011-12-10 22:58:51 UTC
Created attachment 203195 [details] [review]
Simple fix to 656373 in planner.

Please find attached a simple patch to fix this bug.

Cheers,

Josué Abarca
Comment 9 Alexandre Franke 2012-03-05 15:45:11 UTC
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?
Comment 10 Alexandre Franke 2012-03-05 17:30:42 UTC
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.
Comment 11 Alexandre Franke 2012-03-05 17:37:03 UTC
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.
Comment 12 Alexandre Franke 2012-03-09 16:40:14 UTC
*** Bug 669248 has been marked as a duplicate of this bug. ***
Comment 13 Paul Phillips 2012-04-20 05:34:46 UTC
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.
Comment 14 Paul Phillips 2012-05-08 13:48:22 UTC
Created new bug - added patch to :
https://bugzilla.gnome.org/show_bug.cgi?id=675679