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 365282 - temp pdf file created by gtkprintoperation-unix is not removed
temp pdf file created by gtkprintoperation-unix is not removed
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
: 396479 408578 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-10-26 14:06 UTC by Ghee Teo
Modified: 2007-02-23 01:24 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16



Description Ghee Teo 2006-10-26 14:06:54 UTC
Please describe the problem:
gtkprintoperation-unix uses evince to provide the preview capability.
However, the temp file generated by gtkprintoperation is not being cleaned out even after the application exits.

Steps to reproduce:
1. start gtk-demo
2. launch Printing
3. Click on Preview
check out the temp file previewXXXXXX.pdf in iether /tmp/ or /var/tmp
4. exit gtk-demo
temp file is not reoved

Actual results:


Expected results:


Does this happen every time?


Other information:
temp file is created in the function, _gtk_print_operation_platform_backend_create_preview_surface() in
gtkprintoperation-unix.c
Comment 1 Christian Persch 2006-10-26 17:45:29 UTC
     /**
       * GtkSettings:gtk-print-preview-command:
       *
       * A command to run for displaying the print preview. The command
       * should contain a %f placeholder, which will get replaced by
       * the path to the pdf file.
       *
       * The preview application is responsible for removing the pdf file
       * when it is done.
       *
       * Since: 2.10
       */

So I'd say this is a bug in evince.
Comment 2 Ghee Teo 2006-10-27 11:22:37 UTC
I couldn't see what evince can do about this file, since the file is created in gtkprintoperation-unix., evince is spawned as evince --preview %f.
Evince can't simply remove all file it is asked to opened unless it provides an option to do so, like evince --preview-unlink %f

So, it got to be that the gtkprintoperation should take note of the filename it created and at its termination, remove that file.
Just my understanding of this :)
Comment 3 Behdad Esfahbod 2006-10-27 19:36:22 UTC
(In reply to comment #2)
> I couldn't see what evince can do about this file, since the file is created in
> gtkprintoperation-unix., evince is spawned as evince --preview %f.
> Evince can't simply remove all file it is asked to opened unless it provides an
> option to do so, like evince --preview-unlink %f
> 
> So, it got to be that the gtkprintoperation should take note of the filename it
> created and at its termination, remove that file.

This doesn't work either.  "Single-instance" applications like Evince may return instantly and let the running process open the file.

> Just my understanding of this :)

Comment 4 Christian Persch 2006-10-27 21:03:49 UTC
evince --preview is specifically the special mode for gtk print preview, so it should follow the contract and remove the file when it's done. I don't see any problem with that.
Comment 5 Behdad Esfahbod 2006-10-28 20:27:57 UTC
(In reply to comment #4)
> evince --preview is specifically the special mode for gtk print preview, so it
> should follow the contract and remove the file when it's done. I don't see any
> problem with that.

That would be surprising though for anyone else wanting to use evince --preview.  Something like --priview-and-unlink works.
Comment 6 Christian Persch 2006-10-28 22:58:28 UTC
I don't see the problem, since evince --preview was added specifically for print preview mode in gtk, but I'll let evince maints decide.

Re-assigning.
Comment 7 Carlos Garcia Campos 2006-10-29 09:43:13 UTC
Yes, evince --preview was implemented specifically for gtk, but it doesn't mean that preview mode will be used only by gtk. As Behdad said, anyone could want to run evince --preview with an important pdf. 
Maybe something like --preview --unlink-tempfile would solve the problem. 
Comment 8 Ghee Teo 2006-10-31 10:41:03 UTC
Isn't just a --unlink-tempfile is hwat requires of for gtk+ preview? Is there something special between a evince --preview and evince <file>.pdf?
Comment 9 Behdad Esfahbod 2006-10-31 16:39:30 UTC
(In reply to comment #8)
> Is there something special between a evince --preview and evince <file>.pdf?

I think it uses a different interface (no menus, ...?) in preview mode.
Comment 10 Ghee Teo 2006-11-02 18:05:26 UTC
so we need evince --preview --unlink-tempfile=<filename> after all
for gtk+
Comment 11 Carlos Garcia Campos 2006-11-02 18:30:45 UTC
--unlink-tempfile can be boolean, we already know the file uri. Ok, so I'll implement it then. 
Comment 12 Ghee Teo 2006-11-03 15:07:33 UTC
THANKS Carlos. I have logged http://bugzilla.gnome.org/show_bug.cgi?id=370041 to track the other changes required on gtk+ side. Though, that change will have to wait until your change is released, otherwise gtk+ preview will not work,
see 
evince --unlink-tempfile --preview /Desktop/guadec2006-printing.pdf
Unknown option --unlink-tempfile
Run 'evince --help' to see a full list of available command line options.

Comment 13 Christian Persch 2006-11-07 13:11:41 UTC
*** Bug 371975 has been marked as a duplicate of this bug. ***
Comment 14 Carlos Garcia Campos 2006-11-10 17:53:51 UTC
I've just committed a fix. 

Some things:

- The command line option is hidden since it's thought to be used only by applications, not by users. 

- We'll only remove the file if it's under g_get_tmp_dir ()

- The option will only be used in preview mode

We have to be sure we don't delete any file we don't really want to delete. 
Comment 15 Ghee Teo 2006-11-13 11:17:54 UTC
Carlos Rocks :)
Comment 16 Carlos Garcia Campos 2007-01-14 15:43:50 UTC
*** Bug 396479 has been marked as a duplicate of this bug. ***
Comment 17 Christian Persch 2007-02-22 22:16:48 UTC
*** Bug 408578 has been marked as a duplicate of this bug. ***