diff options
Diffstat (limited to 'rbutil/rbutilqt/base/bootloaderinstallsansa.cpp')
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstallsansa.cpp | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp b/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp index b05839e297..061ec2578f 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp +++ b/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp | |||
@@ -27,22 +27,17 @@ BootloaderInstallSansa::BootloaderInstallSansa(QObject *parent) | |||
27 | : BootloaderInstallBase(parent) | 27 | : BootloaderInstallBase(parent) |
28 | { | 28 | { |
29 | (void)parent; | 29 | (void)parent; |
30 | // initialize sector buffer. sansa_sectorbuf is instantiated by | 30 | // initialize sector buffer. The sector buffer is part of the sansa_t |
31 | // sansapatcher. | 31 | // structure, so a second instance of this class will have its own buffer. |
32 | // The buffer itself is only present once, so make sure to not allocate | 32 | sansa_alloc_buffer(&sansa, BUFFER_SIZE); |
33 | // it if it was already allocated. The application needs to take care | ||
34 | // no concurrent (i.e. multiple objects of this class running) requests | ||
35 | // are done. | ||
36 | if(sansa_sectorbuf == NULL) | ||
37 | sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE); | ||
38 | } | 33 | } |
39 | 34 | ||
40 | 35 | ||
41 | BootloaderInstallSansa::~BootloaderInstallSansa() | 36 | BootloaderInstallSansa::~BootloaderInstallSansa() |
42 | { | 37 | { |
43 | if(sansa_sectorbuf) { | 38 | if(sansa.sectorbuf) { |
44 | free(sansa_sectorbuf); | 39 | free(sansa.sectorbuf); |
45 | sansa_sectorbuf = NULL; | 40 | sansa.sectorbuf = NULL; |
46 | } | 41 | } |
47 | } | 42 | } |
48 | 43 | ||
@@ -51,7 +46,7 @@ BootloaderInstallSansa::~BootloaderInstallSansa() | |||
51 | */ | 46 | */ |
52 | bool BootloaderInstallSansa::install(void) | 47 | bool BootloaderInstallSansa::install(void) |
53 | { | 48 | { |
54 | if(sansa_sectorbuf == NULL) { | 49 | if(sansa.sectorbuf == NULL) { |
55 | emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR); | 50 | emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR); |
56 | return false; | 51 | return false; |
57 | emit done(true); | 52 | emit done(true); |
@@ -59,8 +54,6 @@ bool BootloaderInstallSansa::install(void) | |||
59 | 54 | ||
60 | emit logItem(tr("Searching for Sansa"), LOGINFO); | 55 | emit logItem(tr("Searching for Sansa"), LOGINFO); |
61 | 56 | ||
62 | struct sansa_t sansa; | ||
63 | |||
64 | int n = sansa_scan(&sansa); | 57 | int n = sansa_scan(&sansa); |
65 | if(n == -1) { | 58 | if(n == -1) { |
66 | emit logItem(tr("Permission for disc access denied!\n" | 59 | emit logItem(tr("Permission for disc access denied!\n" |
@@ -95,7 +88,6 @@ bool BootloaderInstallSansa::install(void) | |||
95 | */ | 88 | */ |
96 | void BootloaderInstallSansa::installStage2(void) | 89 | void BootloaderInstallSansa::installStage2(void) |
97 | { | 90 | { |
98 | struct sansa_t sansa; | ||
99 | unsigned char* buf = NULL; | 91 | unsigned char* buf = NULL; |
100 | unsigned int len; | 92 | unsigned int len; |
101 | 93 | ||
@@ -174,8 +166,6 @@ void BootloaderInstallSansa::installStage3(bool mounted) | |||
174 | */ | 166 | */ |
175 | bool BootloaderInstallSansa::uninstall(void) | 167 | bool BootloaderInstallSansa::uninstall(void) |
176 | { | 168 | { |
177 | struct sansa_t sansa; | ||
178 | |||
179 | emit logItem(tr("Uninstalling bootloader"), LOGINFO); | 169 | emit logItem(tr("Uninstalling bootloader"), LOGINFO); |
180 | QCoreApplication::processEvents(); | 170 | QCoreApplication::processEvents(); |
181 | 171 | ||
@@ -222,7 +212,6 @@ bool BootloaderInstallSansa::uninstall(void) | |||
222 | */ | 212 | */ |
223 | BootloaderInstallBase::BootloaderType BootloaderInstallSansa::installed(void) | 213 | BootloaderInstallBase::BootloaderType BootloaderInstallSansa::installed(void) |
224 | { | 214 | { |
225 | struct sansa_t sansa; | ||
226 | int num; | 215 | int num; |
227 | 216 | ||
228 | if(!sansaInitialize(&sansa)) { | 217 | if(!sansaInitialize(&sansa)) { |