author | erik <erik> | 2007-01-19 01:18:01 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-19 01:18:01 (UTC) |
commit | 32343107b30904806d02672955c57ed53d39fe79 (patch) (side-by-side diff) | |
tree | 9114a0ea170e3adc807a2445b49360f1bfde9626 /noncore | |
parent | ac0ce844e90a64247c0adb210e0a23021b011d57 (diff) | |
download | opie-32343107b30904806d02672955c57ed53d39fe79.zip opie-32343107b30904806d02672955c57ed53d39fe79.tar.gz opie-32343107b30904806d02672955c57ed53d39fe79.tar.bz2 |
Every file in this commit has a change to check the return value of a call.
-rw-r--r-- | noncore/apps/advancedfm/output.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katebuffer.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 9 |
3 files changed, 13 insertions, 6 deletions
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index 8c585f4..8f654d5 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp @@ -163,66 +163,67 @@ Output::Output( const QStringList commands, QWidget* parent, const char* name, odebug << "" << (*it).latin1() << "" << oendl; * proc << (*it).latin1(); } if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { OutputEdit->append(tr("Process could not start") ); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); perror("Error: "); QString errorMsg=tr("Error\n")+(QString)strerror(errno); OutputEdit->append( errorMsg); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); } } Output::~Output() { } void Output::saveOutput() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = QPEApplication::documentDir(); if(filename.right(1).find('/') == -1) filename+="/"; QString name = fileDlg->LineEdit1->text(); filename+="text/plain/"+name; odebug << filename << oendl; QFile f(filename); - f.open( IO_WriteOnly); - if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { + if ( !f.open( IO_WriteOnly ) ) + owarn << "Could no open file" << oendl; + else if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { DocLnk lnk; lnk.setName(name); //sets file name lnk.setFile(filename); //sets File property lnk.setType("text/plain"); if(!lnk.writeLink()) { odebug << "Writing doclink did not work" << oendl; } } else owarn << "Could not write file" << oendl; f.close(); } } void Output::commandStdout(OProcess*, char *buffer, int buflen) { owarn << "received stdout " << buflen << " bytes" << oendl; // QByteArray data(buflen); // data.fill(*buffer, buflen); // for (uint i = 0; i < data.count(); i++ ) { // printf("%c", buffer[i] ); // } // printf("\n"); QString lineStr = buffer; lineStr=lineStr.left(lineStr.length()-1); OutputEdit->append(lineStr); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); } void Output::commandStdin( const QByteArray &data) { owarn << "received stdin " << data.size() << " bytes" << oendl; diff --git a/noncore/apps/tinykate/libkate/document/katebuffer.cpp b/noncore/apps/tinykate/libkate/document/katebuffer.cpp index 4c15fd0..d89edbd 100644 --- a/noncore/apps/tinykate/libkate/document/katebuffer.cpp +++ b/noncore/apps/tinykate/libkate/document/katebuffer.cpp @@ -43,65 +43,68 @@ #include <assert.h> /** * Create an empty buffer. */ KWBuffer::KWBuffer() { clear(); } void KWBuffer::clear() { m_stringListIt=0; m_stringListCurrent=0; m_stringList.clear(); m_lineCount=1; m_stringListIt = m_stringList.append(new TextLine()); } /** * Insert a file at line @p line in the buffer. */ void KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec) { if (line) { odebug << "insert File only supports insertion at line 0 == file opening" << oendl; return; } clear(); QFile iofile(file); - iofile.open(IO_ReadOnly); + if (!iofile.open(IO_ReadOnly)) { + owarn << "failed to open file " << iofile.name() << oendl; + return; + } QTextStream stream(&iofile); stream.setCodec(codec); QString qsl; int count=0; for (count=0;((qsl=stream.readLine())!=QString::null); count++) { if (count==0) { (*m_stringListIt)->append(qsl.unicode(),qsl.length()); } else { TextLine::Ptr tl=new TextLine(); tl ->append(qsl.unicode(),qsl.length()); m_stringListIt=m_stringList.append(tl); } } if (count!=0) { m_stringListCurrent=count-1; m_lineCount=count; } } void KWBuffer::loadFilePart() { } void KWBuffer::insertData(int line, const QByteArray &data, QTextCodec *codec) diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index 3654639..75a96a6 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp @@ -213,67 +213,70 @@ bool UserDialog::addUser(int uid, int gid) QCheckListItem *temp; QFile ozTest; int oz=false; if(ODevice::inst()->system()==System_OpenZaurus) oz=true; // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); adduserDialog->setCaption(tr("Add User")); adduserDialog->userID=uid; // Set next available UID as default uid. adduserDialog->groupID=gid; // Set next available GID as default gid. // Insert default group into groupComboBox adduserDialog->groupComboBox->insertItem("<create new group>",0); adduserDialog->uidLineEdit->setText(QString::number(uid)); // If we're running on OZ, add new users to some default groups. if(oz) { QListViewItemIterator iter( adduserDialog->groupsListView ); for ( ; iter.current(); ++iter ) { temp=(QCheckListItem*)iter.current(); if (temp->text()=="video") temp->setOn(true); if (temp->text()=="audio") temp->setOn(true); if (temp->text()=="time") temp->setOn(true); if (temp->text()=="power") temp->setOn(true); if (temp->text()=="input") temp->setOn(true); if (temp->text()=="sharp") temp->setOn(true); if (temp->text()=="tty") temp->setOn(true); } } // Show the dialog! if(!(adduserDialog->exec())) return false; if((adduserDialog->groupComboBox->currentItem()!=0)) { - accounts->findGroup(adduserDialog->groupComboBox->currentText()); - adduserDialog->groupID=accounts->gr_gid; - owarn << QString::number(accounts->gr_gid) << oendl; + // making the call findGroup() puts the group info in the accounts gr_gid + if (accounts->findGroup(adduserDialog->groupComboBox->currentText())) + { + adduserDialog->groupID=accounts->gr_gid; + owarn << QString::number(accounts->gr_gid) << oendl; + } } if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); return false; } // Add User to additional groups. QListViewItemIterator it( adduserDialog->groupsListView ); for ( ; it.current(); ++it ) { temp=(QCheckListItem*)it.current(); if (temp->isOn() ) accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); } // Copy image to pics/users/ if(!(adduserDialog->userImage.isNull())) { QDir d; if(!(d.exists(QPEApplication::qpeDir() + "pics/users"))) { d.mkdir(QPEApplication::qpeDir() + "pics/users"); } QString filename= QPEApplication::qpeDir()+"pics/users/"+accounts->pw_name+".png"; // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); adduserDialog->userImage.save(filename,"PNG"); } // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? accounts->findUser(adduserDialog->loginLineEdit->text()); |