summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/base/bootloaderinstallipod.cpp')
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallipod.cpp23
1 files changed, 10 insertions, 13 deletions
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)) {