Martin Delille
Martin Delille

Reputation: 11780

The QFileDialog from my sandboxed application throws deny file-read-xattr error

Since I enabled sandbox on my Qt application, I have many log message in the console when navigating with the QFileDialog:

23/02/2016 12:25:51,000 kernel[0]: Sandbox: Joker(87965) deny file-read-xattr /Users/martin/Documents/a.txt
23/02/2016 12:25:51,000 kernel[0]: Sandbox: Joker(87965) deny file-read-xattr /Users/martin/Documents/b.txt
23/02/2016 12:25:52,000 kernel[0]: Sandbox: Joker(87965) deny file-read-xattr /Users/martin/Documents/c.txt

Is there a way to avoid this?

Upvotes: 0

Views: 136

Answers (1)

TheDarkKnight
TheDarkKnight

Reputation: 27611

As discussed here,

The file save dialog requires a non-empty default filename to work correctly inside a sandbox. You can supply a default filename to the save dialog as follows:

QString fileSavePath = QFileDialog::getSaveFileName(this, "Save file", "default filename");

Or if you create the dialog instance yourself:

QFileDialog *fileSaveDialog = new QFileDialog(this);
fileSaveDialog->setAcceptMode(QFileDialog::AcceptSave);
fileSaveDialog->selectFile("default filename");

You should probably also use a custom info.plist and insert the key ForAppStore, with a value of yes

To build with a custom plist, create the file and reference it in the .pro like this: -

QMAKE_INFO_PLIST = Info.plist

Upvotes: 1

Related Questions