summaryrefslogtreecommitdiff
path: root/utils/rbutilqt/base
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2022-03-08 22:25:48 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2022-03-08 22:32:13 +0100
commit3cebc983a21a753699ae4bc019ee4a517e8f84a7 (patch)
treef7263e3e8d6ec3dabf7d711568501be427008587 /utils/rbutilqt/base
parent911b216afff933609f2be3f7936d766ac7918d0e (diff)
downloadrockbox-3cebc983a21a753699ae4bc019ee4a517e8f84a7.tar.gz
rockbox-3cebc983a21a753699ae4bc019ee4a517e8f84a7.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
Diffstat (limited to 'utils/rbutilqt/base')
-rw-r--r--utils/rbutilqt/base/bootloaderinstallbase.cpp30
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)
116bool BootloaderInstallBase::backup(QString to) 116bool BootloaderInstallBase::backup(QString to)
117{ 117{
118 LOG_INFO() << "Backing up bootloader file"; 118 LOG_INFO() << "Backing up bootloader file";
119 QDir targetDir("."); 119 if(!m_blfile.isEmpty()) {
120 emit logItem(tr("Creating backup of original firmware file."), LOGINFO); 120 QDir targetDir(".");
121 if(!targetDir.mkpath(to)) { 121 emit logItem(tr("Creating backup of original firmware file."), LOGINFO);
122 emit logItem(tr("Creating backup folder failed"), LOGERROR); 122 if(!targetDir.mkpath(to)) {
123 return false; 123 emit logItem(tr("Creating backup folder failed"), LOGERROR);
124 return false;
125 }
126 QString tofile = to + "/" + QFileInfo(m_blfile).fileName();
127 LOG_INFO() << "trying to backup" << m_blfile << "to" << tofile;
128 if(!QFile::copy(Utils::resolvePathCase(m_blfile), tofile)) {
129 emit logItem(tr("Creating backup copy failed."), LOGERROR);
130 return false;
131 }
132 emit logItem(tr("Backup created."), LOGOK);
124 } 133 }
125 QString tofile = to + "/" + QFileInfo(m_blfile).fileName(); 134 else {
126 LOG_INFO() << "trying to backup" << m_blfile << "to" << tofile; 135 LOG_INFO() << "Bootloader backup not supported for current device.";
127 if(!QFile::copy(Utils::resolvePathCase(m_blfile), tofile)) {
128 emit logItem(tr("Creating backup copy failed."), LOGERROR);
129 return false;
130 } 136 }
131 emit logItem(tr("Backup created."), LOGOK);
132 return true; 137 return true;
133} 138}
134 139
@@ -215,9 +220,6 @@ void BootloaderInstallBase::setBlFile(QStringList sl)
215 m_blfile = sl.at(a); 220 m_blfile = sl.at(a);
216 } 221 }
217 } 222 }
218 if(m_blfile.isEmpty()) {
219 m_blfile = sl.at(0);
220 }
221} 223}
222 224
223 225