From 48c2e714379afa104c8afa92977fb5665d777590 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 11 Jan 2016 10:06:12 +0000 Subject: [PATCH] lazbarcodes: Assign useful values to width and height. Fix range overflow error in "Generate". git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4419 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/lazbarcodes/src/ubarcodes.pas | 44 ++++++++++++++---------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/components/lazbarcodes/src/ubarcodes.pas b/components/lazbarcodes/src/ubarcodes.pas index 67784ad84..f7df5f41c 100644 --- a/components/lazbarcodes/src/ubarcodes.pas +++ b/components/lazbarcodes/src/ubarcodes.pas @@ -45,6 +45,8 @@ published property StrictSize: Boolean read GetStrictSize write SetStrictSize; property BackgroundColor: TColor read GetBackgroundColor write SetBackgroundColor default clWhite; property ForegroundColor: TColor read GetForegroundColor write SetForegroundColor default clBlack; + property Width default 88; + property Height default 88; end; { TLazBarcodeCustomText } @@ -281,6 +283,8 @@ begin FBackgroundColor:=clWhite; FForegroundColor:=clBlack; FStrictSize:=true; + Width := 88; + Height := 88; end; destructor TLazBarcodeCustomBase.Destroy; @@ -400,15 +404,17 @@ begin ZBarcode_Delete(FQR); FQR:=nil; end; - FQR:=ZBarcode_Create(); - with FQR^ do begin - border_width:=4; - end; - UpdateECCLevel; - ErrorCode:=qr_code(FQR,@FText[1],Length(FText)); - if ErrorCode<>0 then begin - FLastErrorString:=FQR^.errtxt; - exit; + if Length(FText) > 0 then begin + FQR:=ZBarcode_Create(); + with FQR^ do begin + border_width:=4; + end; + UpdateECCLevel; + ErrorCode:=qr_code(FQR,@FText[1],Length(FText)); + if ErrorCode<>0 then begin + FLastErrorString:=FQR^.errtxt; + exit; + end; end; end; @@ -422,15 +428,17 @@ begin ZBarcode_Delete(FQR); FQR:=nil; end; - FQR:=ZBarcode_Create(); - with FQR^ do begin - border_width:=4; - end; - UpdateECCLevel; - ErrorCode:=microqr(FQR,@FText[1],Length(FText)); - if ErrorCode<>0 then begin - FLastErrorString:=FQR^.errtxt; - exit; + if Length(FText) > 0 then begin + FQR:=ZBarcode_Create(); + with FQR^ do begin + border_width:=4; + end; + UpdateECCLevel; + ErrorCode:=microqr(FQR,@FText[1],Length(FText)); + if ErrorCode<>0 then begin + FLastErrorString:=FQR^.errtxt; + exit; + end; end; end;