TOpenDialog/NSOpenPanel not working in a sandboxed Delphi app

最后都变了- 提交于 2019-12-10 03:56:18

问题


There seems to be a problem with the TOpenDialog in a Firemonkey application, which is sandboxed for the Mac Appstore. I use XE3, but it is also present in XE2. I actually found a QC report here, but it is still unresolved:

http://qc.embarcadero.com/wc/qcmain.aspx?d=105344

Has anyone had the same problem, or any ideas how to work around it?

It is very easy to check. Just put a TOpenDialog on a form and call the Execute method. Sign and sandbox the application according to the Embarcadero instructions:

http://docwiki.embarcadero.com/RADStudio/en/Mac_OS_X_Application_Development

When Execute is called there is a delay, the app freezes for a moment, but nothing is shown. There are no exceptions or error messages. If the app is not sandboxed the dialog works properly.

This code also does not work, so the problem is probably somewhere in the TNSOpenPanel, which is called by the TOpenDialog, but unfortunately I could not find it.

var
  LOpenDir: NSOpenPanel;
begin
  LOpenDir := TNSOpenPanel.Wrap(TNSOpenPanel.OCClass.openPanel);
  LOpenDir.runModal;
  LOpenDir.release;

I read in the Apple docs that with Sandbox the NSOpenPanel is derived from different classes, compared to the one without a sandbox. I guess this is the cause of the problem.

Any ideas would be greatly appreciated. We can't really publish an app that has to work with files without Open/Save dialogs :)

Btw, I tried several combinations of the Entitlements in Project Options, but they had no effect.


回答1:


When an application is in sandbox, NSOpenPanel/NSSavePanel should be managed by a transparent module called Powerbox. The normal panels of AppKit framework has no effect. But to enable Powerbox for access to filesystem, the entitlements list should include

com.apple.security.files.user-selected.read-write YES

configuration.



来源:https://stackoverflow.com/questions/13551879/topendialog-nsopenpanel-not-working-in-a-sandboxed-delphi-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!