diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-12-05 15:14:45 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2014-12-05 15:39:10 +0100 |
commit | 8ee7aa78afd3d3dee6e333953d51aa72cb227441 (patch) | |
tree | c61a84686639a7fdc6ba324dc689abc66090b7e6 | |
parent | 05ad2fc2f4267defd4b9b7f0b8706d2624f10d12 (diff) |
qt_mac_loadMenuNib: Prevent stale NIB files by diffing file size
If we're changing the contents of the nib files in Qt, we need to
overwrite the nib files that we write to /tmp, as QFile::copy() does
not overwrite files.
This also catches the case where the files in /tmp are empty due to
a possible broken qrc-run, where re-runs of qrc to fix the resources
would still leave the corrupt nib in /tmp, resulting in:
-[NSKeyedUnarchiver initForReadingWithData:]: data is empty; did
you forget to send -finishEncoding to the NSKeyedArchiver?
And as a consequence:
qt_mac_loadMenuNib: could not instantiate nib
ASSERT: "mainMenu" in file qcocoamenuloader.mm, line 154
Change-Id: I2907a32d1a56c23a27343c81839a06b65a529372
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamenuloader.mm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm index 9340e945fb..0075dea805 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm @@ -87,7 +87,11 @@ void qt_mac_loadMenuNib(QCocoaMenuLoader *qtMenuLoader) return; } foreach (const QFileInfo &file, nibResource.entryInfoList()) { - QFile::copy(file.absoluteFilePath(), nibDir + QLatin1String("/") + file.fileName()); + QFileInfo destinationFile(nibDir + QLatin1String("/") + file.fileName()); + if (destinationFile.exists() && destinationFile.size() != file.size()) + QFile::remove(destinationFile.absoluteFilePath()); + + QFile::copy(file.absoluteFilePath(), destinationFile.absoluteFilePath()); } // Load and instantiate nib file from temp |