[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kdepim/enterprise4/kdepim/kleopatra/utils
From: Marc Mutz <mutz () kde ! org>
Date: 2010-10-26 16:07:03
Message-ID: 20101026160703.4E0D0AC89A () svn ! kde ! org
[Download RAW message or body]
SVN commit 1190012 by mutz:
Output: allow to call errorString() more than once
M +18 -7 output.cpp
--- branches/kdepim/enterprise4/kdepim/kleopatra/utils/output.cpp #1190011:1190012
@@ -38,6 +38,7 @@
#include "kleo_assert.h"
#include "kdpipeiodevice.h"
#include "log.h"
+#include "cached.h"
#include <kleo/exception.h>
@@ -160,6 +161,7 @@
: Output(),
m_defaultLabel(),
m_customLabel(),
+ m_errorString(),
m_isFinalized( false ),
m_isFinalizing( false ),
m_cancelPending( false ),
@@ -173,10 +175,9 @@
void setDefaultLabel( const QString & l ) { m_defaultLabel = l; }
/* reimp */ QString errorString() const {
- if ( shared_ptr<QIODevice> io = ioDevice() )
- return io->errorString();
- else
- return i18n("No output device");
+ if ( m_errorString.dirty() )
+ m_errorString = doErrorString();
+ return m_errorString;
}
/* reimp */ bool isFinalized() const { return m_isFinalized; }
@@ -205,11 +206,18 @@
}
}
private:
+ virtual QString doErrorString() const {
+ if ( shared_ptr<QIODevice> io = ioDevice() )
+ return io->errorString();
+ else
+ return i18n("No output device");
+ }
virtual void doFinalize() = 0;
virtual void doCancel() = 0;
private:
QString m_defaultLabel;
QString m_customLabel;
+ mutable cached<QString> m_errorString;
bool m_isFinalized : 1;
bool m_isFinalizing : 1;
bool m_cancelPending : 1;
@@ -245,7 +253,8 @@
}
/* reimp */ QString label() const;
- /* reimp */ QString errorString() const;
+ private:
+ /* reimp */ QString doErrorString() const;
private:
const QString m_command;
@@ -280,8 +289,10 @@
/* reimp */ shared_ptr<QIODevice> ioDevice() const { return m_buffer; }
/* reimp */ void doFinalize();
/* reimp */ void doCancel() {}
- /* reimp */ QString errorString() const { return QString(); }
+
private:
+ /* reimp */ QString doErrorString() const { return QString(); }
+ private:
const QClipboard::Mode m_mode;
shared_ptr<QBuffer> m_buffer;
};
@@ -441,7 +452,7 @@
return i18nc( "e.g. \"Input to tar xf - file\"", "Input to %1", cmdline );
}
-QString ProcessStdInOutput::errorString() const {
+QString ProcessStdInOutput::doErrorString() const {
kleo_assert( m_proc );
if ( m_proc->exitStatus() == QProcess::NormalExit && m_proc->exitCode() == 0 )
return QString();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic