diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-03-08 22:25:48 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-03-08 22:32:13 +0100 |
commit | 3cebc983a21a753699ae4bc019ee4a517e8f84a7 (patch) | |
tree | f7263e3e8d6ec3dabf7d711568501be427008587 | |
parent | 911b216afff933609f2be3f7936d766ac7918d0e (diff) | |
download | rockbox-3cebc983a2.tar.gz rockbox-3cebc983a2.zip |
rbutil: Fix a crash for devices without bootloader file.
Don't try to get a bootloader filename from an empty list. This happens
if the device doesn't have a bootloader file on disk.
Change-Id: Idd4c265e7ae298913c5feefb3963120867a0e858
-rw-r--r-- | utils/rbutilqt/base/bootloaderinstallbase.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/utils/rbutilqt/base/bootloaderinstallbase.cpp b/utils/rbutilqt/base/bootloaderinstallbase.cpp index 096c601b91..c07d87bf36 100644 --- a/utils/rbutilqt/base/bootloaderinstallbase.cpp +++ b/utils/rbutilqt/base/bootloaderinstallbase.cpp @@ -116,19 +116,24 @@ void BootloaderInstallBase::progressAborted(void) bool BootloaderInstallBase::backup(QString to) { LOG_INFO() << "Backing up bootloader file"; - QDir targetDir("."); - emit logItem(tr("Creating backup of original firmware file."), LOGINFO); - if(!targetDir.mkpath(to)) { - emit logItem(tr("Creating backup folder failed"), LOGERROR); - return false; + if(!m_blfile.isEmpty()) { + QDir targetDir("."); + emit logItem(tr("Creating backup of original firmware file."), LOGINFO); + if(!targetDir.mkpath(to)) { + emit logItem(tr("Creating backup folder failed"), LOGERROR); + return false; + } + QString tofile = to + "/" + QFileInfo(m_blfile).fileName(); + LOG_INFO() << "trying to backup" << m_blfile << "to" << tofile; + if(!QFile::copy(Utils::resolvePathCase(m_blfile), tofile)) { + emit logItem(tr("Creating backup copy failed."), LOGERROR); + return false; + } + emit logItem(tr("Backup created."), LOGOK); } - QString tofile = to + "/" + QFileInfo(m_blfile).fileName(); - LOG_INFO() << "trying to backup" << m_blfile << "to" << tofile; - if(!QFile::copy(Utils::resolvePathCase(m_blfile), tofile)) { - emit logItem(tr("Creating backup copy failed."), LOGERROR); - return false; + else { + LOG_INFO() << "Bootloader backup not supported for current device."; } - emit logItem(tr("Backup created."), LOGOK); return true; } @@ -215,9 +220,6 @@ void BootloaderInstallBase::setBlFile(QStringList sl) m_blfile = sl.at(a); } } - if(m_blfile.isEmpty()) { - m_blfile = sl.at(0); - } } |