From f131c02f88b6001caf48240e95e5d92aed815f60 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 23 Nov 2019 11:34:00 +0000 Subject: [PATCH] fpspreadsheet: No "invalid index" error message when attempting to save a workbook without reader/writer unit in "uses" git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7197 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/source/common/fpsreaderwriter.pas | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/fpspreadsheet/source/common/fpsreaderwriter.pas b/components/fpspreadsheet/source/common/fpsreaderwriter.pas index 04d0eb3e4..318c08568 100644 --- a/components/fpspreadsheet/source/common/fpsreaderwriter.pas +++ b/components/fpspreadsheet/source/common/fpsreaderwriter.pas @@ -1199,7 +1199,8 @@ begin begin // Bring the priority format to the top idx := IndexOf(APriorityFormat); - FList.Exchange(0, idx); + if idx > -1 then + FList.Exchange(0, idx); end; SetLength(Result, FList.Count); @@ -1224,7 +1225,8 @@ begin if APriorityFormat <> sfidUnknown then // Restore original order - FList.Exchange(idx, 0); + if idx > -1 then + FList.Exchange(idx, 0); end; function TsSpreadFormatRegistry.GetFormatName(AFormatID: TsSpreadFormatID): String;