Skip to content

Commit

Permalink
Refs edbee#35, fixed some coverity scan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gamecreature committed Jun 28, 2017
1 parent 9328ca5 commit 672e1a7
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
cov-int

edbee-test/edbee-test
1 change: 1 addition & 0 deletions edbee-lib/edbee/io/jsonparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ bool JsonParser::parse( QIODevice* device )
errorMessage_ = device->errorString();
return false;
}
opened = true;
}

QByteArray bytesIn = device->readAll();
Expand Down
2 changes: 2 additions & 0 deletions edbee-lib/edbee/models/changes/linedatalistchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ void LineDataListChange::revert(TextDocument* doc)
void LineDataListChange::mergeStoredData(AbstractRangedChange* change)
{
LineDataListChange* lineTextChange = dynamic_cast<LineDataListChange*>(change);
Q_ASSERT(lineTextChange ); // this shouldn't happen
if( !lineTextChange ) return;

// calculate the new size
int newOldListSize = getMergedStoredLength( change);// qlog_info() << "CALCULATED: " << newOldListSize ;
Expand Down
6 changes: 4 additions & 2 deletions edbee-lib/edbee/models/changes/mergablechangegroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,10 @@ QString MergableChangeGroup::toSingleTextChangeTestString()
QString result;
foreach( AbstractRangedChange* abstractChange, textChangeList_ ) {
TextChange* change = dynamic_cast<TextChange*>(abstractChange);
if( !result.isEmpty() ) result.append(",");
result.append( QString("%1:%2:%3").arg(change->offset()).arg(change->docLength()).arg(change->storedText()) );
if( change ) {
if( !result.isEmpty() ) result.append(",");
result.append( QString("%1:%2:%3").arg(change->offset()).arg(change->docLength()).arg(change->storedText()) );
}
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion edbee-lib/edbee/util/mem/debug_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void* operator new[] (size_t size, const char* file, const int line)
/// the delete array operator
void operator delete[] (void* p, const char* file, const int line)
{
delete[] p;
// delete[] p; << This is strange!!
return debug_free(p, file, line);
}

Expand Down
6 changes: 5 additions & 1 deletion edbee-lib/edbee/util/regexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class OnigRegExpEngine : public RegExpEngine
: reg_(0)
, region_(0)
, pattern_(pattern)
, lineRef_(0)
{
const QChar* patternChars = pattern.constData();

Expand Down Expand Up @@ -389,11 +390,14 @@ RegExp::RegExp( const QString& pattern, bool caseSensitive, Syntax syntax, Engin
case EngineQRegExp:
d_ = new QtRegExpEngine(pattern, caseSensitive, syntax);
break;
case EngineOniguruma:
d_ = new OnigRegExpEngine(pattern, caseSensitive, syntax);
break;
default:
Q_ASSERT(false);
qlog_warn() << "Invalid engine supplied to RegExp. Falling back to EngineOniguruma";
case EngineOniguruma:
d_ = new OnigRegExpEngine(pattern, caseSensitive, syntax);
break;
}
}

Expand Down
6 changes: 3 additions & 3 deletions edbee-lib/edbee/util/simpleprofiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ void SimpleProfiler::dumpResults()
}

foreach( ProfilerItem* item, items ) {
double durationPercentage = 100.0 * item->duration() / totalDuration;
double callCountPercentage = 100.0 * item->callCount() / totalCallCount;
double durationWithoutChildsPercenage = 100.0 * item->durationWithoutChilds() / totalDurationWitoutChilds;
double durationPercentage = totalDuration > 0 ? 100.0 * item->duration() / totalDuration : 100;
double callCountPercentage = totalCallCount > 0 ? 100.0 * item->callCount() / totalCallCount : 100;
double durationWithoutChildsPercenage = totalDurationWitoutChilds > 0 ? 100.0 * item->durationWithoutChilds() / totalDurationWitoutChilds : 100;

QString line = QString("%1x(%2%) %3ms(%4%) %5ms(%6%) | %7:%8 %9")
.arg(item->callCount(),8).arg( callCountPercentage, 6, 'f', 2 )
Expand Down
1 change: 1 addition & 0 deletions edbee-lib/edbee/views/components/texteditorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static const int ShadowWidth=5;

TextEditorRenderer::TextEditorRenderer( TextRenderer *renderer )
: rendererRef_(renderer)
, themeRef_(0)
, shadowGradient_(0)
{
shadowGradient_ = new QLinearGradient( 0, 0, ShadowWidth, 0 );
Expand Down
4 changes: 4 additions & 0 deletions edbee-lib/edbee/views/textrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ TextRenderer::TextRenderer(TextEditorController* controller)
, totalWidthCache_(0)
, textThemeStyler_(0)
, clipRectRef_(0)
, startOffset_(0)
, endOffset_(0)
, startLine_(0)
, endLine_(0)
{
connect( controller, SIGNAL(textDocumentChanged(edbee::TextDocument*,edbee::TextDocument*)), this, SLOT(textDocumentChanged(edbee::TextDocument*,edbee::TextDocument*)));
textThemeStyler_ = new TextThemeStyler( controller );
Expand Down

0 comments on commit 672e1a7

Please sign in to comment.