mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 16:21:45 +01:00 
			
		
		
		
	printe4lazarus: raise exception, if tmp file cannot be created
git-svn-id: trunk@50173 -
This commit is contained in:
		
							parent
							
								
									7cdf5a2bb6
								
							
						
					
					
						commit
						a46caecea3
					
				| @ -1509,6 +1509,13 @@ begin | ||||
|   cairo_ps_surface_dsc_begin_setup(sf); | ||||
|   cairo_ps_surface_dsc_comment(sf, PChar(s)); | ||||
| 
 | ||||
|   if (fStream=nil) and not FileExists(FOutputFileName) then | ||||
|   begin | ||||
|     DebugLn('Error: unable to write cairo ps to "'+FOutputFileName+'"'); | ||||
|     DestroyCairoHandle; | ||||
|     exit(0); | ||||
|   end; | ||||
| 
 | ||||
|   //rotate and move | ||||
|   case Orientation of | ||||
|     poLandscape: begin | ||||
|  | ||||
| @ -473,6 +473,8 @@ var | ||||
|   aPrinterName : string; | ||||
| begin | ||||
|   Result:=-1; | ||||
|   if aFileName='' then | ||||
|     raise Exception.Create('TCUPSPrinter.PrintFile missing Filename'); | ||||
|   if not CUPSLibInstalled then Exit; | ||||
|   aFileName:=ExpandFileNameUTF8(aFileName); | ||||
| 
 | ||||
| @ -846,6 +848,7 @@ end; | ||||
| procedure TCUPSPrinter.DoBeginDoc; | ||||
| var | ||||
|   NewPath: String; | ||||
|   fs: TFileStream; | ||||
| 
 | ||||
|   function TryTemporaryPath(const Path: string): Boolean; | ||||
|   var | ||||
| @ -879,6 +882,15 @@ begin | ||||
|     FOutputFileName := FOutputFileName + '.ps'; | ||||
|     TFilePrinterCanvas(Canvas).OutputFileName := FOutputFileName; | ||||
|   end; | ||||
| 
 | ||||
|   // test writing, on error this raises exception showing the user the filename
 | ||||
|   fs:=TFileStream.Create(FOutputFilename,fmCreate); | ||||
|   try | ||||
|     fs.Write(FOutputFilename[1],1); | ||||
|   finally | ||||
|     fs.free; | ||||
|   end; | ||||
|   DeleteFileUTF8(FOutputFilename); | ||||
| end; | ||||
| 
 | ||||
| //If not aborted, send PostScript file to printer.
 | ||||
| @ -902,9 +914,11 @@ begin | ||||
|     end; | ||||
|      | ||||
|   end else | ||||
|     TFilePrinterCanvas(Canvas).OutPutFileName:=''; | ||||
|     TFilePrinterCanvas(Canvas).OutputFileName:=''; | ||||
| 
 | ||||
|   if not aAborted and FileExistsUTF8(FOutputFileName) then begin | ||||
|   if not aAborted then begin | ||||
|     if not FileExistsUTF8(FOutputFileName) then | ||||
|       raise Exception.Create('Unable to write to "'+FOutputFileName+'"'); | ||||
|     {$IFDEF LogPrintoutFile} | ||||
|     CopyFile(FOutputFileName, 'printjob'+ExtractFileExt(FOutputFileName)); | ||||
|     {$ENDIF} | ||||
| @ -916,7 +930,6 @@ begin | ||||
|     {$ENDIF} | ||||
|     DeleteFileUTF8(FOutputFilename); | ||||
|   end; | ||||
| 
 | ||||
| end; | ||||
| 
 | ||||
| procedure TCUPSPrinter.DoResetPrintersList; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 mattias
						mattias