summaryrefslogtreecommitdiff
path: root/noncore/apps
Side-by-side diff
Diffstat (limited to 'noncore/apps') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/output.cpp5
-rw-r--r--noncore/apps/tinykate/libkate/document/katebuffer.cpp5
2 files changed, 7 insertions, 3 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
@@ -171,50 +171,51 @@ Output::Output( const QStringList commands, QWidget* parent, const char* name,
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;
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
@@ -51,49 +51,52 @@ KWBuffer::KWBuffer()
}
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;
}
}