Recent

Author Topic: Broken file dialogs on Windows  (Read 384 times)

CCRDude

  • Hero Member
  • *****
  • Posts: 517
Broken file dialogs on Windows
« on: April 16, 2021, 01:23:29 pm »
I've got a project I compiled last year, Lazarus 2.1.0 rc62299, FPC 3.3.
Today I compiled, then updated laz/fpc trunk, now Lazarus 2.1.0 rc56006, FPC 3.3.1.

I use file dialogs in some places. TFileOpen action type, but sometimes directly, e.g. TSelectDirectoryDialog.

These dialogs have in common that in rc62299 they worked as expected, and in the past weeks, the process simply freezes instead of opening the requested system dialog.

Bart

  • Hero Member
  • *****
  • Posts: 4250
    • Bart en Mariska's Webstek
Re: Broken file dialogs on Windows
« Reply #1 on: April 16, 2021, 03:46:06 pm »
Is this inside the debugger, or outside?

Bart

CCRDude

  • Hero Member
  • *****
  • Posts: 517
Re: Broken file dialogs on Windows
« Reply #2 on: April 21, 2021, 12:49:01 pm »
Both actually.

It simply freezes.

And I found the problem: I do use
Code: [Select]
CoInitializeEx(nil, COINIT_MULTITHREADED). Switching to
Code: [Select]
COINIT_APARTMENTTHREADED, dialogs work.

Previously, I think both worked. Anyway, with standard LCL controls, I didn't expect conflicts with my COM stuff.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9269
  • FPC developer.
Re: Broken file dialogs on Windows
« Reply #3 on: April 21, 2021, 12:55:12 pm »
IFileDialog is a COM object.

CCRDude

  • Hero Member
  • *****
  • Posts: 517
Re: Broken file dialogs on Windows
« Reply #4 on: April 21, 2021, 03:00:14 pm »
Thanks, that explains it!

Wouldn't it make sense to print a compiler warning about calls to CoInitializeEx with the wrong parameter if the LCL is included in the projects requirements?

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9269
  • FPC developer.
Re: Broken file dialogs on Windows
« Reply #5 on: April 21, 2021, 04:19:26 pm »
Thanks, that explains it!

Wouldn't it make sense to print a compiler warning about calls to CoInitializeEx with the wrong parameter if the LCL is included in the projects requirements?

I don't think so. Moreover, the compiler doesn't know what the LCL is.

 

TinyPortal © 2005-2018