author | erik <erik> | 2007-01-24 19:54:07 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-24 19:54:07 (UTC) |
commit | 89e81059e832ff77c2f0ac8b9db12f80eafa03fc (patch) (unidiff) | |
tree | 99a130fc643d2aeefdecab452f644e7b61a5f50e /noncore/apps/checkbook/mainwindow.cpp | |
parent | 035bbc5bf689839c8d8e7be37f347b0dd900fccf (diff) | |
download | opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.zip opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.gz opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.bz2 |
Each file in this commit has an instance where a pointer is checked at
one point in the code and then not checked in another point in the code.
If it needed to be checked once, it needs to be checked the other time. If not
the application could segfault.
Diffstat (limited to 'noncore/apps/checkbook/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index d9e2047..8e2e2e3 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -222,86 +222,85 @@ void MainWindow::slotNew() | |||
222 | cb->setFilename( tempFilename ); | 222 | cb->setFilename( tempFilename ); |
223 | cb->write(); | 223 | cb->write(); |
224 | 224 | ||
225 | // Add to listbox | 225 | // Add to listbox |
226 | checkbooks->inSort( cb ); | 226 | checkbooks->inSort( cb ); |
227 | addCheckbook( cb ); | 227 | addCheckbook( cb ); |
228 | } | 228 | } |
229 | delete currcb; | 229 | delete currcb; |
230 | } | 230 | } |
231 | 231 | ||
232 | // --- slotEdit --------------------------------------------------------------- | 232 | // --- slotEdit --------------------------------------------------------------- |
233 | void MainWindow::slotEdit() | 233 | void MainWindow::slotEdit() |
234 | { | 234 | { |
235 | // get name and open it | 235 | // get name and open it |
236 | QListViewItem *curritem = cbList->currentItem(); | 236 | QListViewItem *curritem = cbList->currentItem(); |
237 | if ( !curritem ) | 237 | if ( !curritem ) |
238 | return; | 238 | return; |
239 | openBook( curritem ); | 239 | openBook( curritem ); |
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | // --- openBook --------------------------------------------------------------- | 243 | // --- openBook --------------------------------------------------------------- |
244 | void MainWindow::openBook(QListViewItem *curritem) | 244 | void MainWindow::openBook(QListViewItem *curritem) |
245 | { | 245 | { |
246 | if ( !curritem ) return; | ||
246 | // find book in List | 247 | // find book in List |
247 | QString currname=curritem->text(posName); | 248 | QString currname=curritem->text(posName); |
248 | CBInfo *cb = checkbooks->first(); | 249 | CBInfo *cb = checkbooks->first(); |
249 | while ( cb ) { | 250 | while ( cb ) { |
250 | if ( cb->name() == currname ) | 251 | if ( cb->name() == currname ) |
251 | break; | 252 | break; |
252 | cb = checkbooks->next(); | 253 | cb = checkbooks->next(); |
253 | } | 254 | } |
254 | if ( !cb ) return; | 255 | if ( !cb ) return; |
255 | 256 | ||
256 | // | 257 | // |
257 | buildFilename( currname ); | 258 | buildFilename( currname ); |
258 | float currbalance = cb->balance(); | 259 | float currbalance = cb->balance(); |
259 | bool currlock = !cb->password().isNull(); | 260 | bool currlock = !cb->password().isNull(); |
260 | 261 | ||
261 | if ( currlock ) | 262 | if ( currlock ) |
262 | { | 263 | { |
263 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 264 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
264 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) | 265 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) |
265 | { | 266 | { |
266 | delete pw; | 267 | delete pw; |
267 | return; | 268 | return; |
268 | } | 269 | } |
269 | delete pw; | 270 | delete pw; |
270 | } | 271 | } |
271 | 272 | ||
272 | _cfg.setLastBook( currname ); | 273 | _cfg.setLastBook( currname ); |
273 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); | 274 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); |
274 | if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) | 275 | if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) |
275 | { | 276 | { |
276 | QString newname = cb->name(); | 277 | QString newname = cb->name(); |
277 | if ( currname != newname ) | 278 | if ( currname != newname ) |
278 | { | 279 | { |
279 | // Update name if changed | 280 | // Update name if changed |
280 | if( curritem ) { | 281 | curritem->setText( posName, newname ); |
281 | curritem->setText( posName, newname ); | 282 | cbList->sort(); |
282 | cbList->sort(); | ||
283 | } | ||
284 | _cfg.setLastBook( newname ); | 283 | _cfg.setLastBook( newname ); |
285 | 284 | ||
286 | // Remove old file | 285 | // Remove old file |
287 | QFile f( tempFilename ); | 286 | QFile f( tempFilename ); |
288 | if ( f.exists() ) | 287 | if ( f.exists() ) |
289 | f.remove(); | 288 | f.remove(); |
290 | 289 | ||
291 | // Get new filename | 290 | // Get new filename |
292 | buildFilename( newname ); | 291 | buildFilename( newname ); |
293 | cb->setFilename( tempFilename ); | 292 | cb->setFilename( tempFilename ); |
294 | } | 293 | } |
295 | 294 | ||
296 | cb->write(); | 295 | cb->write(); |
297 | 296 | ||
298 | // Update lock if changed | 297 | // Update lock if changed |
299 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) | 298 | if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) |
300 | { | 299 | { |
301 | if ( !cb->password().isNull() ) | 300 | if ( !cb->password().isNull() ) |
302 | curritem->setPixmap( 0, lockIcon ); | 301 | curritem->setPixmap( 0, lockIcon ); |
303 | else | 302 | else |
304 | curritem->setPixmap( 0, nullIcon ); | 303 | curritem->setPixmap( 0, nullIcon ); |
305 | } | 304 | } |
306 | 305 | ||
307 | // Update balance if changed | 306 | // Update balance if changed |