From 9e6e76425a44069cf0bd285ccfa0fc432caeb461 Mon Sep 17 00:00:00 2001 From: Stephen Lyons Date: Fri, 30 Oct 2015 02:43:26 +0000 Subject: [PATCH] Bugfix/Enhance: Suppress debug output from short interval timers Adds a spinbox control to the last page of the profile preferences that allows the user to set an interval for which any Timer less than this will NOT dump it's command and script content to the debug console in dark yellow on a blue background EVERY time it fires. The Execute OK line will still show up in green - so the timer can be seen to be firing but the windows will not fill up with spammy text so much. Also: I also spotted and corrected a couple of lines above my addition to dlgProfilePreferences::slot_save_and_exit() where the unchecked global pointer to the Host (mpHost) was being used instead of the local checked pointer (pHost) which is a copy of it and used everywhere else in the method. Signed-off-by: Stephen Lyons --- src/Host.h | 8 ++++ src/TTimer.cpp | 57 ++++++++++++++------------- src/dlgProfilePreferences.cpp | 16 +++++++- src/ui/profile_preferences.ui | 73 ++++++++++++++++++++++++++++------- 4 files changed, 112 insertions(+), 42 deletions(-) diff --git a/src/Host.h b/src/Host.h index 64b0af00896..0899b4894b2 100644 --- a/src/Host.h +++ b/src/Host.h @@ -321,6 +321,14 @@ class Host : public QObject bool mFORCE_MXP_NEGOTIATION_OFF; bool mHaveMapperScript; QSet mDoubleClickIgnore; + int mTimerDebugOutputSuppressionInterval; + // Set from last page of profile preferences if the + // timer interval is less than this in milliseconds then + // the normal reoccuring debug output of the entire + // command and script for any timer with a timeout LESS + // than this is NOT shown - this is so the spammy output + // from short timeout timers can be suppressed. The + // single execute OK line will still be shown. }; #endif // MUDLET_HOST_H diff --git a/src/TTimer.cpp b/src/TTimer.cpp index c9adbf13aed..96a1d28163b 100644 --- a/src/TTimer.cpp +++ b/src/TTimer.cpp @@ -237,22 +237,29 @@ bool TTimer::checkRestart() void TTimer::execute() { - if( ! isActive() || mIsFolder ) - { + if( ! isActive() || mIsFolder ) { mpTimer->stop(); return; } - if( mudlet::debugMode ) {TDebug(QColor(Qt::darkYellow),QColor(Qt::darkBlue)) << "\n[TIMER EXECUTES]: "<> 0;} + if( mudlet::debugMode + && mpTimer->interval() > mpHost->mTimerDebugOutputSuppressionInterval ) { + // Second term is to suppress execution debug output from short interval timers + TDebug( QColor(Qt::darkYellow), QColor(Qt::darkBlue) ) << "\n[TIMER EXECUTES]: " + << mName + << " fired. Executing command=" + << mCommand + << " and executing script:" + << mScript + << "\n" + >> 0; + } - if( mIsTempTimer ) - { - if( mScript == "" ) - { + if( mIsTempTimer ) { + if( mScript.isEmpty() ) { mpHost->mLuaInterpreter.call_luafunction( this ); } - else - { + else { mpHost->mLuaInterpreter.compileAndExecuteScript( mScript ); } mpTimer->stop(); @@ -260,41 +267,37 @@ void TTimer::execute() return; } - if( ( ! isFolder() && hasChildren() ) || ( isOffsetTimer() ) ) - { + if( ( ! isFolder() && hasChildren() ) + || ( isOffsetTimer() ) ) { + typedef list::const_iterator I; - for( I it = mpMyChildrenList->begin(); it != mpMyChildrenList->end(); it++) - { + for( I it = mpMyChildrenList->begin(); + it != mpMyChildrenList->end(); + ++it ) { + TTimer * pChild = *it; - if( pChild->isOffsetTimer() ) - { + if( pChild->isOffsetTimer() ) { pChild->enableTimer( pChild->getID() ); } } - if( isOffsetTimer() ) - { + if( isOffsetTimer() ) { disableTimer( mID ); deactivate(); } } - if( mCommand.size() > 0 ) - { + if( ! mCommand.isEmpty() ) { mpHost->send( mCommand ); } - if( mScript.size() > 0 ) - { - if( mNeedsToBeCompiled ) - { - if( ! compileScript() ) - { + if( ! mScript.isEmpty() ) { + if( mNeedsToBeCompiled ) { + if( ! compileScript() ) { disableTimer(); return; } } - if( ! mpHost->mLuaInterpreter.call( mFuncName, mName ) ) - { + if( ! mpHost->mLuaInterpreter.call( mFuncName, mName ) ) { mpTimer->stop(); } } diff --git a/src/dlgProfilePreferences.cpp b/src/dlgProfilePreferences.cpp index f559e299183..74a961c22cd 100644 --- a/src/dlgProfilePreferences.cpp +++ b/src/dlgProfilePreferences.cpp @@ -456,6 +456,10 @@ dlgProfilePreferences::dlgProfilePreferences( QWidget * pF, Host * pH ) ignore = ignore.append(it.next()); doubleclick_ignore_lineedit->setText( ignore ); + timeEdit_timerDebugOutputMinimumInterval->setTime( QTime( 0, 0, 0, 1).addMSecs( pHost->mTimerDebugOutputSuppressionInterval - 1 ) ); + // The above funky setting method is because a zero time is INVALID + // and since Qt 5.0-ish adding any value to an invalid time still leaves + // the time as "invalid". } } @@ -1544,9 +1548,17 @@ void dlgProfilePreferences::slot_save_and_exit() mudlet::self()->mConsoleMap[pHost]->changeColors(); } QString lIgnore = doubleclick_ignore_lineedit->text(); - mpHost->mDoubleClickIgnore.clear(); + pHost->mDoubleClickIgnore.clear(); for(int i=0;imDoubleClickIgnore.insert(lIgnore.at(i)); + pHost->mDoubleClickIgnore.insert(lIgnore.at(i)); + } + QTime _midnight( 0, 0, 0, 1 ); + // zero time is NOT valid and QTime::msecsTo( const QTime & other ) returns + // 0 if EITHER time is invalid + pHost->mTimerDebugOutputSuppressionInterval = _midnight.msecsTo( timeEdit_timerDebugOutputMinimumInterval->time() ) - 1; + if( pHost->mTimerDebugOutputSuppressionInterval < 0 ) { + // Clean up if the control IS at zero, so the msecTo() fails and returns 0 + pHost->mTimerDebugOutputSuppressionInterval = 0; } //pHost->mIRCNick = ircNick->text(); diff --git a/src/ui/profile_preferences.ui b/src/ui/profile_preferences.ui index 2102ccd5d72..24340dd24b6 100644 --- a/src/ui/profile_preferences.ui +++ b/src/ui/profile_preferences.ui @@ -1810,19 +1810,6 @@ or some other computer model that has a small screen. Special Options - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -1888,6 +1875,66 @@ or some other computer model that has a small screen. + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Other Special options + + + + + + Minimum interval for a Timer to show execution output in debug window: + + + + + + + + 200 + 16777215 + + + + Qt::AlignCenter + + + QAbstractSpinBox::PlusMinus + + + show all + + + true + + + true + + + QDateTimeEdit::HourSection + + + h:mm:ss.zzz + + + + + +