mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
store temporary PDF files outside the LyX tmpbuf to prevent file locking problems when LyX is closed while Adobe Reader is still open
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15742 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8cc9180ba8
commit
a3b98687fa
@ -35,7 +35,9 @@ SilentInstall silent
|
|||||||
;Variables
|
;Variables
|
||||||
|
|
||||||
Var Dummy
|
Var Dummy
|
||||||
Var FileName
|
Var OriginalFile
|
||||||
|
Var OriginalFileName
|
||||||
|
Var PDFFile
|
||||||
Var Viewer
|
Var Viewer
|
||||||
Var OriginalTimeHigh
|
Var OriginalTimeHigh
|
||||||
Var OriginalTimeLow
|
Var OriginalTimeLow
|
||||||
@ -69,24 +71,33 @@ Var CurrentTimeLow
|
|||||||
|
|
||||||
Section "View PDF file"
|
Section "View PDF file"
|
||||||
|
|
||||||
|
InitPluginsDir ;Temporary directory for PDF file
|
||||||
|
|
||||||
;Command line parameters
|
;Command line parameters
|
||||||
Call GetParameters
|
Call GetParameters
|
||||||
Pop $FileName
|
Pop $OriginalFile
|
||||||
|
|
||||||
;Trim quotes
|
;Trim quotes
|
||||||
StrCpy $Dummy $FileName 1
|
StrCpy $Dummy $OriginalFile 1
|
||||||
${if} $Dummy == '"'
|
${if} $Dummy == '"'
|
||||||
StrCpy $FileName $FileName "" 1
|
StrCpy $OriginalFile $OriginalFile "" 1
|
||||||
${endif}
|
${endif}
|
||||||
StrCpy $Dummy $FileName 1 -1
|
StrCpy $Dummy $OriginalFile 1 -1
|
||||||
${if} $Dummy == '"'
|
${if} $Dummy == '"'
|
||||||
StrCpy $FileName $FileName -1
|
StrCpy $OriginalFile $OriginalFile -1
|
||||||
${endif}
|
${endif}
|
||||||
|
|
||||||
GetFullPathName $FileName $FileName
|
GetFullPathName $OriginalFile $OriginalFile
|
||||||
|
Push $OriginalFile
|
||||||
|
Call GetFileName
|
||||||
|
Pop $OriginalFileName
|
||||||
|
|
||||||
|
SetOutPath $TEMP ;The LyX tmpbuf should not be locked
|
||||||
|
|
||||||
|
StrCpy $PDFFile $PLUGINSDIR\$OriginalFileName
|
||||||
|
|
||||||
;Check whether the file will be opened with Adobe Reader or Adobe Acrobat
|
;Check whether the file will be opened with Adobe Reader or Adobe Acrobat
|
||||||
Push $FileName
|
Push $OriginalFile
|
||||||
!insertmacro SystemCall "shell32::FindExecutable(t s, t '', t .s)"
|
!insertmacro SystemCall "shell32::FindExecutable(t s, t '', t .s)"
|
||||||
Call GetFileName
|
Call GetFileName
|
||||||
Pop $Viewer
|
Pop $Viewer
|
||||||
@ -97,51 +108,49 @@ Section "View PDF file"
|
|||||||
;Using Adobe viewer
|
;Using Adobe viewer
|
||||||
|
|
||||||
;Close existing view
|
;Close existing view
|
||||||
${if} ${fileexists} $FileName~
|
${if} ${fileexists} $PDFFile
|
||||||
!insertmacro HideConsole '"$EXEDIR\pdfclose.exe" --file "$FileName~"'
|
!insertmacro HideConsole '"$EXEDIR\pdfclose.exe" --file "$PDFFile"'
|
||||||
${endif}
|
${endif}
|
||||||
|
|
||||||
;Copy PDF to temporary file to allow LyX to overwrite the original
|
;Copy PDF to temporary file to allow LyX to overwrite the original
|
||||||
CopyFiles /SILENT $FileName $FileName~
|
CopyFiles /SILENT $OriginalFile $PDFFile
|
||||||
|
|
||||||
;Open a new view
|
;Open a new view
|
||||||
!insertmacro HideConsole '"$EXEDIR\pdfopen.exe" --back --file "$FileName~"'
|
!insertmacro HideConsole '"$EXEDIR\pdfopen.exe" --back --file "$PDFFile"'
|
||||||
|
|
||||||
;Monitor for updates of the original file
|
;Monitor for updates of the original file
|
||||||
|
|
||||||
GetFileTime $FileName $OriginalTimeHigh $OriginalTimeLow
|
GetFileTime $OriginalFile $OriginalTimeHigh $OriginalTimeLow
|
||||||
|
|
||||||
${do}
|
${do}
|
||||||
|
|
||||||
Sleep 500
|
Sleep 500
|
||||||
|
|
||||||
FileOpen $Dummy $FileName~ a
|
FileOpen $Dummy $PDFFile a
|
||||||
|
|
||||||
${if} $Dummy != ""
|
${if} $Dummy != ""
|
||||||
;File no longer locked, reader closed
|
;File no longer locked, reader closed
|
||||||
FileClose $Dummy
|
FileClose $Dummy
|
||||||
Delete $FileName~
|
Delete $PDFFile
|
||||||
Quit
|
Quit
|
||||||
${endif}
|
${endif}
|
||||||
|
|
||||||
${unless} ${fileexists} $FileName
|
${if} ${fileexists} $OriginalFile
|
||||||
;Original no longer exists
|
|
||||||
Delete $FileName~
|
|
||||||
Quit
|
|
||||||
${endif}
|
|
||||||
|
|
||||||
GetFileTime $FileName $CurrentTimeHigh $CurrentTimeLow
|
|
||||||
|
|
||||||
${if} $OriginalTimeHigh != $CurrentTimeHigh
|
|
||||||
${orif} $OriginalTimeLow != $CurrentTimeLow
|
|
||||||
|
|
||||||
;Original has been modified, update!
|
GetFileTime $OriginalFile $CurrentTimeHigh $CurrentTimeLow
|
||||||
|
|
||||||
StrCpy $OriginalTimeHigh $CurrentTimeHigh
|
${if} $OriginalTimeHigh != $CurrentTimeHigh
|
||||||
StrCpy $OriginalTimeLow $CurrentTimeLow
|
${orif} $OriginalTimeLow != $CurrentTimeLow
|
||||||
!insertmacro HideConsole '"$EXEDIR\pdfclose.exe" --file "$FileName~"'
|
|
||||||
CopyFiles /SILENT $FileName $FileName~
|
;Original has been modified, update!
|
||||||
!insertmacro HideConsole '"$EXEDIR\pdfopen.exe" --back --file "$FileName~"'
|
|
||||||
|
StrCpy $OriginalTimeHigh $CurrentTimeHigh
|
||||||
|
StrCpy $OriginalTimeLow $CurrentTimeLow
|
||||||
|
!insertmacro HideConsole '"$EXEDIR\pdfclose.exe" --file "$PDFFile"'
|
||||||
|
CopyFiles /SILENT $OriginalFile $PDFFile
|
||||||
|
!insertmacro HideConsole '"$EXEDIR\pdfopen.exe" --back --file "$PDFFile"'
|
||||||
|
|
||||||
|
${endif}
|
||||||
|
|
||||||
${endif}
|
${endif}
|
||||||
|
|
||||||
@ -151,7 +160,7 @@ Section "View PDF file"
|
|||||||
|
|
||||||
;Another PDF viewer like GSView is used
|
;Another PDF viewer like GSView is used
|
||||||
;No need for special actions, just forward to ShellExecute
|
;No need for special actions, just forward to ShellExecute
|
||||||
ExecShell open $FileName
|
ExecShell open $OriginalFile
|
||||||
|
|
||||||
${endif}
|
${endif}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user