Lazarus

Programming => Widgetset => Cocoa => Topic started by: apeoperaio on October 13, 2021, 11:20:22 am

Title: [SOLVED] FilterIndex error when using CocoaUseUTIFilter := true;
Post by: apeoperaio on October 13, 2021, 11:20:22 am
I encountered an issue when using an OpenDialog and

CocoaUseUTIFilter := true;

https://wiki.freepascal.org/Cocoa_Internals/Dialogs#File_Type_Filters

If I use the same opendialog with different filters I get a List Index out of bounds.
I attached a sample project to reproduce the error. Steps to reproduce:
- compile and run the attached project;
- click on button1
- select a file and click open in the opendialog
- click on button2
- error raised

When executing the opendialog on button1 the opendialog has 2 filters and filterindex is set to 2.
When executing the opendialog on button2 the opendialog has only 1 filter.

The error is not raised if I set in Button2Click

OpenDialog1.FilterIndex:= 1

before

OpenDialog1.Execute

On Windows and Linux I do not need to reset the filterindex.

I do not get the error if
 CocoaUseUTIFilter := False;


My version is:
Lazarus 2.1.0 r65062M FPC 3.2.0 x86_64-darwin-cocoa
Title: Re: FIlterIndex error when using CocoaUseUTIFilter := true;
Post by: skalogryz on October 18, 2021, 04:25:57 am
should be fixed here (https://github.com/skalogryz/Lazarus/commit/8629f0f2b126d7137559d7273258a7c28c7a6bac)
Title: Re: [SOLVED] FilterIndex error when using CocoaUseUTIFilter := true;
Post by: apeoperaio on October 19, 2021, 02:47:21 pm
Tested, it works!
Thank you.
TinyPortal © 2005-2018