summaryrefslogtreecommitdiff
path: root/noncore
authorerik <erik>2007-01-26 20:22:50 (UTC)
committer erik <erik>2007-01-26 20:22:50 (UTC)
commit53d630c9c4813142ee13e6843c30476a5db26e78 (patch) (unidiff)
tree50a77a94cfeaccbb3d993bced8b7d0f498f74c7c /noncore
parent152a8fe978851aea8dac6ae5cb11f73540746b83 (diff)
downloadopie-53d630c9c4813142ee13e6843c30476a5db26e78.zip
opie-53d630c9c4813142ee13e6843c30476a5db26e78.tar.gz
opie-53d630c9c4813142ee13e6843c30476a5db26e78.tar.bz2
Each file in this commit exhibit an example of what prevent calls
'reverse inull'. All that means is that a pointer gets dereferenced. Then a pointer gets checked for validity before being dereferenced again. This almost always points to shenanigans. For example, the konsole.cpp file has this konsoleInit() call which passes in a const char** shell variable. Since it is a double pointer the programmer who wrote the code made the mistake of mixing the checking of the pointer and the pointer that points to the pointer. This commit attempts to correct that. Of course there are other instances of the same thing. But they all boil down to a small mistake which might have produced strange side effects.
Diffstat (limited to 'noncore') (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp2
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index 13f297e..61a47d7 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -214,49 +214,49 @@ void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) {
214 break; 214 break;
215 }; 215 };
216} 216}
217 217
218void NotesControl::slotBoxSelected(const QString &itemString) { 218void NotesControl::slotBoxSelected(const QString &itemString) {
219 if(edited) { 219 if(edited) {
220 save(); 220 save();
221 } 221 }
222 loaded=false; 222 loaded=false;
223 edited=false; 223 edited=false;
224 load(itemString); 224 load(itemString);
225} 225}
226 226
227 227
228void NotesControl::showMenu() { 228void NotesControl::showMenu() {
229 QPopupMenu *m = new QPopupMenu(0); 229 QPopupMenu *m = new QPopupMenu(0);
230 m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() )); 230 m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() ));
231 m->insertItem( tr( "Search For..." ), this, SLOT( slotSearch() )); 231 m->insertItem( tr( "Search For..." ), this, SLOT( slotSearch() ));
232 m->insertItem( tr( "Toggle Maximized" ), this, SLOT( slotShowMax() )); 232 m->insertItem( tr( "Toggle Maximized" ), this, SLOT( slotShowMax() ));
233 m->insertSeparator(); 233 m->insertSeparator();
234 m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() )); 234 m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() ));
235 m->setFocus(); 235 m->setFocus();
236 m->exec( QCursor::pos() ); 236 m->exec( QCursor::pos() );
237 237
238 if(m) delete m; 238 delete m;
239} 239}
240 240
241void NotesControl::focusOutEvent ( QFocusEvent * e) { 241void NotesControl::focusOutEvent ( QFocusEvent * e) {
242 if( e->reason() == QFocusEvent::Popup) 242 if( e->reason() == QFocusEvent::Popup)
243 save(); 243 save();
244 else { 244 else {
245 if(!loaded) { 245 if(!loaded) {
246 populateBox(); 246 populateBox();
247 load(); 247 load();
248 } 248 }
249 } 249 }
250 QWidget::focusOutEvent(e); 250 QWidget::focusOutEvent(e);
251} 251}
252 252
253void NotesControl::save() { 253void NotesControl::save() {
254 Config cfg("Notes"); 254 Config cfg("Notes");
255 cfg.setGroup("Docs"); 255 cfg.setGroup("Docs");
256 if( edited) { 256 if( edited) {
257// odebug << "is edited" << oendl; 257// odebug << "is edited" << oendl;
258 QString rt = view->text(); 258 QString rt = view->text();
259 if( rt.length()>1) { 259 if( rt.length()>1) {
260 QString pt = rt.simplifyWhiteSpace(); 260 QString pt = rt.simplifyWhiteSpace();
261 int i = pt.find( ' ', pt.find( ' ' )+2 ); 261 int i = pt.find( ' ', pt.find( ' ' )+2 );
262 QString docname = pt; 262 QString docname = pt;
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 828f5a1..cf19ba8 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -475,49 +475,49 @@ void AdvancedFm::showFileMenu() {
475 n->insertItem(tr("Delete"),this,SLOT(doDelete())); 475 n->insertItem(tr("Delete"),this,SLOT(doDelete()));
476 m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); 476 m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs()));
477 477
478 m->insertItem(tr("Run Command"),this,SLOT(runCommand())); 478 m->insertItem(tr("Run Command"),this,SLOT(runCommand()));
479 m->insertItem(tr("File Info"),this,SLOT(fileStatus())); 479 m->insertItem(tr("File Info"),this,SLOT(fileStatus()));
480 480
481 m->insertSeparator(); 481 m->insertSeparator();
482 m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); 482 m->insertItem(tr("Set Permissions"),this,SLOT(filePerms()));
483 483
484#if defined(QT_QWS_OPIE) 484#if defined(QT_QWS_OPIE)
485 m->insertItem(tr("Properties"),this,SLOT(doProperties())); 485 m->insertItem(tr("Properties"),this,SLOT(doProperties()));
486#endif 486#endif
487 m->setCheckable(TRUE); 487 m->setCheckable(TRUE);
488 if (!b) 488 if (!b)
489 m->setItemChecked(m->idAt(0),TRUE); 489 m->setItemChecked(m->idAt(0),TRUE);
490 else 490 else
491 m->setItemChecked(m->idAt(0),FALSE); 491 m->setItemChecked(m->idAt(0),FALSE);
492 492
493 if(Ir::supported()) 493 if(Ir::supported())
494 m->insertItem(tr("Beam File"),this,SLOT(doBeam())); 494 m->insertItem(tr("Beam File"),this,SLOT(doBeam()));
495 m->setFocus(); 495 m->setFocus();
496 496
497 m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); 497 m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y()));
498 498
499 if(m) delete m; 499 delete m;
500} 500}
501 501
502 502
503QString AdvancedFm::checkDiskSpace(const QString &path) { 503QString AdvancedFm::checkDiskSpace(const QString &path) {
504 struct statfs fss; 504 struct statfs fss;
505 if ( !statfs( path.latin1(), &fss ) ) { 505 if ( !statfs( path.latin1(), &fss ) ) {
506 int blkSize = fss.f_bsize; 506 int blkSize = fss.f_bsize;
507// int totalBlks = fs.f_blocks; 507// int totalBlks = fs.f_blocks;
508 int availBlks = fss.f_bavail; 508 int availBlks = fss.f_bavail;
509 509
510 long mult = blkSize / 1024; 510 long mult = blkSize / 1024;
511 long div = 1024 / blkSize; 511 long div = 1024 / blkSize;
512 if ( !mult ) mult = 1; 512 if ( !mult ) mult = 1;
513 if ( !div ) div = 1; 513 if ( !div ) div = 1;
514 514
515 515
516 return QString::number(availBlks * mult / div); 516 return QString::number(availBlks * mult / div);
517 } 517 }
518 return ""; 518 return "";
519} 519}
520 520
521void AdvancedFm::addToDocs() { 521void AdvancedFm::addToDocs() {
522 QStringList strListPaths = getPath(); 522 QStringList strListPaths = getPath();
523 QDir *thisDir = CurrentDir(); 523 QDir *thisDir = CurrentDir();