diff options
-rw-r--r-- | utils/ipodpatcher/ipodio-posix.c | 1 | ||||
-rw-r--r-- | utils/ipodpatcher/ipodio-win32.c | 1 | ||||
-rw-r--r-- | utils/rbutilqt/base/bootloaderinstallipod.cpp | 28 |
3 files changed, 17 insertions, 13 deletions
diff --git a/utils/ipodpatcher/ipodio-posix.c b/utils/ipodpatcher/ipodio-posix.c index 9b386d994f..dc856a2e0d 100644 --- a/utils/ipodpatcher/ipodio-posix.c +++ b/utils/ipodpatcher/ipodio-posix.c | |||
@@ -355,6 +355,7 @@ int ipod_reopen_rw(struct ipod_t* ipod) | |||
355 | int ipod_close(struct ipod_t* ipod) | 355 | int ipod_close(struct ipod_t* ipod) |
356 | { | 356 | { |
357 | close(ipod->dh); | 357 | close(ipod->dh); |
358 | ipod->dh = -1; | ||
358 | return 0; | 359 | return 0; |
359 | } | 360 | } |
360 | 361 | ||
diff --git a/utils/ipodpatcher/ipodio-win32.c b/utils/ipodpatcher/ipodio-win32.c index cea218774a..2c52a64658 100644 --- a/utils/ipodpatcher/ipodio-win32.c +++ b/utils/ipodpatcher/ipodio-win32.c | |||
@@ -155,6 +155,7 @@ int ipod_close(struct ipod_t* ipod) | |||
155 | { | 155 | { |
156 | unlock_volume(ipod->dh); | 156 | unlock_volume(ipod->dh); |
157 | CloseHandle(ipod->dh); | 157 | CloseHandle(ipod->dh); |
158 | ipod->dh = INVALID_HANDLE_VALUE; | ||
158 | return 0; | 159 | return 0; |
159 | } | 160 | } |
160 | 161 | ||
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) { |