mirror of https://github.com/qt/qtbase.git
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>
This commit is contained in:
parent
05ad2fc2f4
commit
8ee7aa78af
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue