[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Mon Apr 4 03:39:10 CEST 2005
CVS commit by staikos:
kstdebug can be used from threads so emitting the signal was a bad idea,
especially when it triggered UI code.
M +1 -0 kst.cpp 1.300
M +17 -12 kstdebug.cpp 1.17
M +5 -2 kstdebug.h 1.16
M +3 -1 kstdebugdialog_i.cpp 1.13
M +3 -0 kstdoc.cpp 1.159
M +1 -0 kstdoc.h 1.40
M +1 -0 kstevents.h 1.11
--- kdeextragear-2/kst/kst/kst.cpp #1.299:1.300
@@ -118,4 +118,5 @@ KstApp::KstApp(QWidget *parent, const ch
initDocument();
+ KstDebug::self()->setHandler(doc);
setCaption(doc->title());
--- kdeextragear-2/kst/kst/kstdebug.cpp #1.16:1.17
@@ -16,6 +16,9 @@
***************************************************************************/
+#include "kst.h"
#include "kstdatasource.h"
#include "kstdebug.h"
+#include "kstdoc.h"
+#include "kstevents.h"
#include "kstversion.h"
@@ -60,4 +63,9 @@ QStringList KstDebug::dataSourcePlugins(
+void KstDebug::setHandler(QObject *handler) {
+ _handler = handler;
+}
+
+
void KstDebug::log(const QString& msg, LogLevel level) {
QMutexLocker ml(&_lock);
@@ -69,13 +77,8 @@ void KstDebug::log(const QString& msg, L
_messages.append(message);
- if (_applyLimit) {
- if ((int)_messages.size() > _limit) {
- QValueListIterator<LogMessage> first;
- QValueListIterator<LogMessage> last;
-
- first = _messages.begin();
- last = first;
+ if (_applyLimit && int(_messages.size()) > _limit) {
+ QValueListIterator<LogMessage> first = _messages.begin();
+ QValueListIterator<LogMessage> last = first;
last += _messages.size() - _limit;
-
_messages.erase(first, last);
}
@@ -80,7 +83,9 @@ void KstDebug::log(const QString& msg, L
_messages.erase(first, last);
}
- }
- emit logAdded();
+ if (_handler) {
+ QEvent *e = new QEvent(QEvent(QEvent::Type(KstEventTypeLog)));
+ QApplication::postEvent(_handler, e);
+ }
}
--- kdeextragear-2/kst/kst/kstdebug.h #1.15:1.16
@@ -20,4 +20,5 @@
#include <qdatetime.h>
+#include <qguardedptr.h>
#include <qobject.h>
#include <qmutex.h>
@@ -54,6 +55,7 @@ class KST_EXPORT KstDebug : public QObje
#endif
- signals:
- void logAdded();
+ protected:
+ friend class KstApp;
+ void setHandler(QObject *handler);
private:
@@ -70,4 +72,5 @@ class KST_EXPORT KstDebug : public QObje
QMap<QString,int> _drawCounter;
#endif
+ QGuardedPtr<QObject> _handler;
};
--- kdeextragear-2/kst/kst/kstdebugdialog_i.cpp #1.12:1.13
@@ -27,6 +27,8 @@
#include <klocale.h>
+#include "kst.h"
#include "kstdatacollection.h"
#include "kstdebugdialog_i.h"
+#include "kstdoc.h"
#include "kstlogtable.h"
#include "kstversion.h"
@@ -70,5 +72,5 @@ KstDebugDialogI::KstDebugDialogI(QWidget
_table->setRowMovingEnabled(false);
- connect(KstDebug::self(), SIGNAL(logAdded()), this, SLOT(logAdded()));
+ connect(KstApp::inst()->document(), SIGNAL(logAdded()), this, SLOT(logAdded()));
connect(_email, SIGNAL(clicked()), this, SLOT(email()));
connect(_clear, SIGNAL(clicked()), this, SLOT(clear()));
--- kdeextragear-2/kst/kst/kstdoc.cpp #1.158:1.159
@@ -919,4 +919,7 @@ bool KstDoc::event(QEvent *e) {
return true;
+ } else if (e->type() == KstEventTypeLog) {
+ emit logAdded();
+ return true;
}
--- kdeextragear-2/kst/kst/kstdoc.h #1.39:1.40
@@ -107,4 +107,5 @@ signals:
void dataChanged();
void updateDialogs();
+ void logAdded();
};
--- kdeextragear-2/kst/kst/kstevents.h #1.10:1.11
@@ -32,4 +32,5 @@ class QWidget;
#define KstELOGAliveEvent (QEvent::User + 6)
#define KstELOGDeathEvent (QEvent::User + 7)
+#define KstEventTypeLog (QEvent::User + 8)
struct KstELOGCaptureStruct {
More information about the Kst
mailing list