summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp8
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallipod.cpp23
2 files changed, 14 insertions, 17 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index 0206502202..8fba1d8cea 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -137,9 +137,9 @@ bool Autodetection::detect()
137 int n; 137 int n;
138 // try ipodpatcher 138 // try ipodpatcher
139 // initialize sector buffer. Needed. 139 // initialize sector buffer. Needed.
140 ipod_sectorbuf = NULL;
141 ipod_alloc_buffer(&ipod_sectorbuf, BUFFER_SIZE);
142 struct ipod_t ipod; 140 struct ipod_t ipod;
141 ipod.sectorbuf = NULL;
142 ipod_alloc_buffer(&ipod, BUFFER_SIZE);
143 n = ipod_scan(&ipod); 143 n = ipod_scan(&ipod);
144 if(n == 1) { 144 if(n == 1) {
145 qDebug() << "[Autodetect] Ipod found:" << ipod.modelstr << "at" << ipod.diskname; 145 qDebug() << "[Autodetect] Ipod found:" << ipod.modelstr << "at" << ipod.diskname;
@@ -162,8 +162,8 @@ bool Autodetection::detect()
162 else { 162 else {
163 qDebug() << "[Autodetect] ipodpatcher: no Ipod found." << n; 163 qDebug() << "[Autodetect] ipodpatcher: no Ipod found." << n;
164 } 164 }
165 free(ipod_sectorbuf); 165 free(ipod.sectorbuf);
166 ipod_sectorbuf = NULL; 166 ipod.sectorbuf = NULL;
167 167
168 // try sansapatcher 168 // try sansapatcher
169 // initialize sector buffer. Needed. 169 // initialize sector buffer. Needed.
diff --git a/rbutil/rbutilqt/base/bootloaderinstallipod.cpp b/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
index 249da13735..3d90663392 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
+++ b/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
@@ -28,33 +28,32 @@ BootloaderInstallIpod::BootloaderInstallIpod(QObject *parent)
28 : BootloaderInstallBase(parent) 28 : BootloaderInstallBase(parent)
29{ 29{
30 (void)parent; 30 (void)parent;
31 // initialize sector buffer. ipod_sectorbuf is defined in ipodpatcher. 31 // initialize sector buffer. The sector buffer is part of the ipod_t
32 // The buffer itself is only present once, so make sure to not allocate 32 // structure, so a second instance of this class will have its own buffer.
33 // it if it was already allocated. The application needs to take care 33 ipod_alloc_buffer(&ipod, BUFFER_SIZE);
34 // no concurrent (i.e. multiple objects of this class running) requests
35 // are done.
36 if(ipod_sectorbuf == NULL)
37 ipod_alloc_buffer(&ipod_sectorbuf, BUFFER_SIZE);
38} 34}
39 35
40 36
41BootloaderInstallIpod::~BootloaderInstallIpod() 37BootloaderInstallIpod::~BootloaderInstallIpod()
42{ 38{
43 if(ipod_sectorbuf) { 39 if(ipod.sectorbuf) {
44 free(ipod_sectorbuf); 40 free(ipod.sectorbuf);
45 ipod_sectorbuf = NULL; 41 ipod.sectorbuf = NULL;
46 } 42 }
47} 43}
48 44
49 45
50bool BootloaderInstallIpod::install(void) 46bool BootloaderInstallIpod::install(void)
51{ 47{
52 if(ipod_sectorbuf == NULL) { 48 if(ipod.sectorbuf == NULL) {
53 emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR); 49 emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR);
54 emit done(true); 50 emit done(true);
55 return false; 51 return false;
56 } 52 }
53 // save buffer pointer before cleaning up ipod_t structure
54 unsigned char* sb = ipod.sectorbuf;
57 memset(&ipod, 0, sizeof(struct ipod_t)); 55 memset(&ipod, 0, sizeof(struct ipod_t));
56 ipod.sectorbuf = sb;
58 57
59 if(!ipodInitialize(&ipod)) { 58 if(!ipodInitialize(&ipod)) {
60 emit done(true); 59 emit done(true);
@@ -139,7 +138,6 @@ void BootloaderInstallIpod::installStage3(bool mounted)
139 138
140bool BootloaderInstallIpod::uninstall(void) 139bool BootloaderInstallIpod::uninstall(void)
141{ 140{
142 struct ipod_t ipod;
143 emit logItem(tr("Uninstalling bootloader"), LOGINFO); 141 emit logItem(tr("Uninstalling bootloader"), LOGINFO);
144 QCoreApplication::processEvents(); 142 QCoreApplication::processEvents();
145 143
@@ -190,7 +188,6 @@ bool BootloaderInstallIpod::uninstall(void)
190 188
191BootloaderInstallBase::BootloaderType BootloaderInstallIpod::installed(void) 189BootloaderInstallBase::BootloaderType BootloaderInstallIpod::installed(void)
192{ 190{
193 struct ipod_t ipod;
194 BootloaderInstallBase::BootloaderType result = BootloaderRockbox; 191 BootloaderInstallBase::BootloaderType result = BootloaderRockbox;
195 192
196 if(!ipodInitialize(&ipod)) { 193 if(!ipodInitialize(&ipod)) {