diff options
Diffstat (limited to 'utils/rbutilqt/base/bootloaderinstallipod.cpp')
-rw-r--r-- | utils/rbutilqt/base/bootloaderinstallipod.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/utils/rbutilqt/base/bootloaderinstallipod.cpp b/utils/rbutilqt/base/bootloaderinstallipod.cpp index c556ea27d3..a809b813c0 100644 --- a/utils/rbutilqt/base/bootloaderinstallipod.cpp +++ b/utils/rbutilqt/base/bootloaderinstallipod.cpp | |||
@@ -42,19 +42,6 @@ BootloaderInstallIpod::~BootloaderInstallIpod() | |||
42 | 42 | ||
43 | bool BootloaderInstallIpod::install(void) | 43 | bool BootloaderInstallIpod::install(void) |
44 | { | 44 | { |
45 | ipodInitialize(&ipod); | ||
46 | |||
47 | if(ipod.sectorbuf == nullptr) { | ||
48 | emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR); | ||
49 | emit done(true); | ||
50 | return false; | ||
51 | } | ||
52 | |||
53 | // save buffer pointer before cleaning up ipod_t structure | ||
54 | unsigned char* sb = ipod.sectorbuf; | ||
55 | memset(&ipod, 0, sizeof(struct ipod_t)); | ||
56 | ipod.sectorbuf = sb; | ||
57 | |||
58 | if(!ipodInitialize(&ipod)) { | 45 | if(!ipodInitialize(&ipod)) { |
59 | emit done(true); | 46 | emit done(true); |
60 | return false; | 47 | return false; |
@@ -223,6 +210,21 @@ BootloaderInstallBase::Capabilities BootloaderInstallIpod::capabilities(void) | |||
223 | */ | 210 | */ |
224 | bool BootloaderInstallIpod::ipodInitialize(struct ipod_t *ipod) | 211 | bool BootloaderInstallIpod::ipodInitialize(struct ipod_t *ipod) |
225 | { | 212 | { |
213 | // if the ipod was already opened make sure to close it first. | ||
214 | #if defined(Q_OS_WIN32) | ||
215 | if(ipod->dh != INVALID_HANDLE_VALUE) | ||
216 | #else | ||
217 | if(ipod->dh >= 0) | ||
218 | #endif | ||
219 | { | ||
220 | ipod_close(ipod); | ||
221 | } | ||
222 | |||
223 | // save buffer pointer before cleaning up ipod_t structure | ||
224 | unsigned char* sb = ipod->sectorbuf; | ||
225 | memset(ipod, 0, sizeof(struct ipod_t)); | ||
226 | ipod->sectorbuf = sb; | ||
227 | |||
226 | // initialize sector buffer. The sector buffer is part of the ipod_t | 228 | // initialize sector buffer. The sector buffer is part of the ipod_t |
227 | // structure, so a second instance of this class will have its own buffer. | 229 | // structure, so a second instance of this class will have its own buffer. |
228 | if(ipod->sectorbuf == nullptr) { | 230 | if(ipod->sectorbuf == nullptr) { |