Lots of emails... short summary: 1) Changing the DocFileName constructor definition does not help. 2) filename and igp.filename in InsetGraphicsParams::copy always have identical saveAbsPath() values 3) common_path is not called on paste (see below).
On Dec 8, 2010, at 11:35 AM, Enrico Forestieri wrote: > On Wed, Dec 08, 2010 at 06:19:54PM +0100, Vincent van Ravesteijn wrote: > >> This log indicates to me that outputFilename is able to make a >> relative path with the same input, so my feeling says it really is >> this save_abs_path_ boolean that differs. > > Maybe. The only way to know what really happens is setting a > breakpoint in GuiGraphics.cpp at the place where name is initialized > > string const name = > igp.filename.outputFilename(fromqstr(bufferFilepath())); > > and then step through the outputFilename() call. This can only be done > by a Mac user, though. I am very convinced that save_abs_path_ is true in the pasted graphics, but I don't really know how to debug on Mac. Anyway, I think the following is helpful anyway. I added some debug stuff into common_path and pasteClipboardText. This is what I get when I copy the original image: insets/InsetGraphicsParams.cpp(89): igp:/Users/ct/Desktop/WAN_map.pdf saveAbsPath()=0 insets/InsetGraphicsParams.cpp(90): this: /Users/ct/Desktop/WAN_map.pdf saveAbsPath()=0 [... repeated a few times ...] insets/InsetGraphicsParams.cpp(89): igp:/Users/ct/Desktop/WAN_map.pdf saveAbsPath()=0 insets/InsetGraphicsParams.cpp(90): this: /Users/ct/Desktop/WAN_map.pdf saveAbsPath()=0 ./../support/os_unix.cpp(81): common_path(/Users/ct/Desktop/WAN_map.pdf, /var/folders/av/avLkelJXHKW+1CEnugF2qk+++TI/-Tmp-/) ./../support/os_unix.cpp(83): common_path(/Users/ct/Desktop/WAN_map.pdf, /var/folders/av/avLkelJXHKW+1CEnugF2qk+++TI/-Tmp-/): __APPLE__ is defined ./../support/os_unix.cpp(100): common_path(/Users/ct/Desktop/WAN_map.pdf, /var/folders/av/avLkelJXHKW+1CEnugF2qk+++TI/-Tmp-/) -> 0 And below is what I get when I paste the image. There is an absolute path in the LyX string and there is no call to common_path. In fact, there is a call to DocFileName::set with the absolute image filename and "/" as parameters. Since the image filename is an absolute path, save_abs_path_ will be set to true. Yesterday, I traced the calling sequence (by reading the code) to this: pasteClipboardText [CutAndPaste.cpp, 912] Buffer::readString [Buffer.cpp, 695] Buffer::readFile(Lexer,...) [Buffer.cpp, 752] Buffer::readDocument [Buffer.cpp, 568] Text::read [Text.cpp, 1311] readParagraph [Text.cpp, 248] readParToken [Text.cpp, 84] readInset [factory.cpp, 420] InsetGraphics::read [InsetGraphics.cpp, 286] readInsetGraphics [InsetGraphics.cpp, 127] InsetGraphicsParams::Read [InsetGraphicsParams.cpp, 188] DocFileName::set [FileName.cpp, 1073] And the two parameters to set() are the filename from the pasted LyX text and the buffer path – but of the temporary buffer that was created (with empty filename) in pasteClipboardText. There is no conversion between absolute and relative paths anywhere (or at least, I can't see it), which makes me wondering why it would behave differently in Linux/Windows. ===== LONG DEBUG OUTPUT ON PASTE GRAPHICS ===== CutAndPaste.cpp(923): [BEGIN theClipboard().getAsLyX()] CutAndPaste.cpp(924): #LyX 1.6.8 created this file. For more info see http://www.lyx.org/ \lyxformat 345 \begin_document \begin_header \textclass article \use_default_options true \language english \inputencoding auto \font_roman default \font_sans default \font_typewriter default \font_default_family default \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100 \graphics default \paperfontsize default \use_hyperref false \papersize default \use_geometry false \use_amsmath 1 \use_esint 1 \cite_engine basic \use_bibtopic false \paperorientation portrait \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language english \papercolumns 1 \papersides 1 \paperpagestyle default \tracking_changes false \output_changes false \author "" \end_header \begin_body \begin_layout Plain Layout \begin_inset Graphics filename /Users/ct/Desktop/WAN_map.pdf lyxscale 10 \end_inset \end_layout \end_body \end_document CutAndPaste.cpp(925): [END theClipboard().getAsLyX()] insets/InsetGraphics.cpp(136): Token: 'filename' FileName.cpp(1076): DocFileName::set(/Users/ct/Desktop/WAN_map.pdf, /): save_abs_path_ = 1 insets/InsetGraphics.cpp(136): Token: 'lyxscale' insets/InsetGraphics.cpp(136): Token: '\end_inset' insets/InsetGraphicsParams.cpp(89): igp:/Users/ct/Desktop/WAN_map.pdf saveAbsPath()=0 insets/InsetGraphicsParams.cpp(90): this: /Users/ct/Desktop/WAN_map.pdf saveAbsPath()=0 insets/InsetGraphicsParams.cpp(89): igp:/Users/ct/Desktop/WAN_map.pdf saveAbsPath()=1 insets/InsetGraphicsParams.cpp(90): this: /Users/ct/Desktop/WAN_map.pdf saveAbsPath()=1 insets/InsetGraphicsParams.cpp(89): igp:/Users/ct/Desktop/WAN_map.pdf saveAbsPath()=1 insets/InsetGraphicsParams.cpp(90): this: /Users/ct/Desktop/WAN_map.pdf saveAbsPath()=1