CVS commit by mutz: - Speed up CRL cache dumping by an insane 4-digit percentage by o using QTextEdit with LogText format and o only updating the output window every second - kill the process when closing the window, so it doesn't continue to suck CPU M +25 -5 crlview.cpp 1.7 M +10 -2 crlview.h 1.4 --- kdepim/certmanager/crlview.cpp #1.6:1.7 @@ -42,9 +42,11 @@ #include #include +#include #include #include -#include +#include #include +#include CRLView::CRLView( QWidget* parent, const char* name, bool modal ) @@ -55,6 +57,7 @@ CRLView::CRLView( QWidget* parent, const topLayout->addWidget( new QLabel( i18n("CRL cache dump:"), this ) ); - _textView = new QTextView( this ); - _textView->setWordWrap( QTextEdit::NoWrap ); + _textView = new QTextEdit( this ); + _textView->setFont( KGlobalSettings::fixedFont() ); + _textView->setTextFormat( QTextEdit::LogText ); topLayout->addWidget( _textView ); @@ -76,9 +79,17 @@ CRLView::CRLView( QWidget* parent, const resize( _textView->fontMetrics().width( 'M' ) * 80, _textView->fontMetrics().lineSpacing() * 25 ); + + _timer = new QTimer( this ); + connect( _timer, SIGNAL(timeout()), SLOT(slotAppendBuffer()) ); } CRLView::~CRLView() { - delete _process; + delete _process; _process = 0; +} + +void CRLView::closeEvent( QCloseEvent * e ) { + QDialog::closeEvent( e ); + delete _process; _process = 0; } @@ -87,4 +98,5 @@ void CRLView::slotUpdateView() _updateButton->setEnabled( false ); _textView->clear(); + _buffer = QString::null; if( _process == 0 ) { _process = new KProcess(); @@ -100,13 +112,21 @@ void CRLView::slotUpdateView() slotProcessExited(); } + _timer->start( 1000 ); } void CRLView::slotReadStdout( KProcess*, char* buf, int len) { - _textView->append( QString::fromUtf8( buf, len ) ); + _buffer.append( QString::fromUtf8( buf, len ) ); +} + +void CRLView::slotAppendBuffer() { + _textView->append( _buffer ); + _buffer = QString::null; } void CRLView::slotProcessExited() { + _timer->stop(); + slotAppendBuffer(); _updateButton->setEnabled( true ); --- kdepim/certmanager/crlview.h #1.3:1.4 @@ -35,8 +35,10 @@ #include +#include -class QTextView; +class QTextEdit; class QPushButton; class KProcess; +class QTimer; class CRLView : public QDialog { @@ -51,10 +53,16 @@ protected slots: void slotReadStdout( KProcess*, char* buf, int len); void slotProcessExited(); + void slotAppendBuffer(); + +protected: + void closeEvent( QCloseEvent * ); private: - QTextView* _textView; + QTextEdit* _textView; QPushButton* _updateButton; QPushButton* _closeButton; KProcess* _process; + QTimer* _timer; + QString _buffer; };