Skip to content

Commit

Permalink
Fix a few clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
poire-z committed Sep 14, 2019
1 parent 04fc187 commit 6ed9d00
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
7 changes: 4 additions & 3 deletions crengine/src/lvrend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2029,7 +2029,6 @@ lString16 renderListItemMarker( ldomNode * enode, int & marker_width, LFormatted
// (todo: replace 'fmt' with 'int basewidth' to avoid confusion)
void renderFinalBlock( ldomNode * enode, LFormattedText * txform, RenderRectAccessor * fmt, int & baseflags, int ident, int line_h, int valign_dy, bool * is_link_start )
{
int txform_src_count = txform->GetSrcCount(); // to track if we added lines to txform
if ( enode->isElement() ) {
lvdom_element_render_method rm = enode->getRendMethod();
if ( rm == erm_invisible )
Expand Down Expand Up @@ -2724,6 +2723,8 @@ void renderFinalBlock( ldomNode * enode, LFormattedText * txform, RenderRectAcce
case css_c_both:
baseflags |= LTEXT_SRC_IS_CLEAR_BOTH;
break;
default:
break;
}
}
//baseflags &= ~LTEXT_RUNIN_FLAG;
Expand Down Expand Up @@ -3470,7 +3471,7 @@ int renderBlockElementLegacy( LVRendPageContext & context, ldomNode * enode, int
// is erm_invisible)
// (No need to do anything when list-style-type none.)
ldomNode * tmpnode = enode;
while ( tmpnode->hasChildren() ) {
while ( tmpnode && tmpnode->hasChildren() ) {
tmpnode = tmpnode->getChildNode( 0 );
if (tmpnode && tmpnode->getRendMethod() == erm_final) {
// We need renderFinalBlock() to be able to reach the current
Expand Down Expand Up @@ -5827,7 +5828,7 @@ void renderBlockElementEnhanced( FlowState * flow, ldomNode * enode, int x, int
// is erm_invisible)
// (No need to do anything when list-style-type none.)
ldomNode * tmpnode = enode;
while ( tmpnode->hasChildren() ) {
while ( tmpnode && tmpnode->hasChildren() ) {
tmpnode = tmpnode->getChildNode( 0 );
if (tmpnode && tmpnode->getRendMethod() == erm_final) {
// We need renderFinalBlock() to be able to reach the current
Expand Down
1 change: 1 addition & 0 deletions crengine/src/lvtextfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3424,6 +3424,7 @@ void LFormattedText::Draw( LVDrawBuf * buf, int x, int y, ldomMarkedRangeList *
DrawDocument( *buf, node, x0, y0, dx, dy, doc_x, doc_y, page_height, absmarks, bookmarks );
}
}
delete absmarks;
}

#endif
18 changes: 11 additions & 7 deletions crengine/src/lvtinydom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5392,7 +5392,7 @@ void ldomNode::initNodeRendMethod()
// (If new floats appear after loading, we won't render well, but
// a style hash mismatch will happen and the user will be
// suggested to reload the book with cache cleaned.)
if ( this->getDocument()->_cacheFile == NULL ) {
if ( parent && this->getDocument()->_cacheFile == NULL ) {
// Replace this element with a floatBox in its parent children collection,
// and move it inside, as the single child of this floatBox.
int pos = getNodeIndex();
Expand Down Expand Up @@ -5732,7 +5732,7 @@ ldomNode * ldomDocumentWriter::OnTagOpen( const lChar16 * nsname, const lChar16
// if we see a BODY coming and we are a DocFragment, its time to apply the
// styles set to the DocFragment before switching to BODY (so the styles can
// be applied to BODY)
if (id == el_body && _currNode->_element->getNodeId() == el_DocFragment) {
if (id == el_body && _currNode && _currNode->_element->getNodeId() == el_DocFragment) {
_currNode->_stylesheetIsSet = _currNode->getElement()->applyNodeStylesheet();
// _stylesheetIsSet will be used to pop() the stylesheet when
// leaving/destroying this DocFragment ldomElementWriter
Expand Down Expand Up @@ -6604,7 +6604,7 @@ bool ldomXPointer::getRect(lvRect & rect, bool extended, bool adjusted) const
//CRLog::trace("ldomXPointer::getRect() - p==NULL");
}
//printf("getRect( p=%08X type=%d )\n", (unsigned)p, (int)p->getNodeType() );
if ( !p->getDocument() ) {
else if ( !p->getDocument() ) {
//CRLog::trace("ldomXPointer::getRect() - p->getDocument()==NULL");
}
ldomNode * mainNode = p->getDocument()->getRootNode();
Expand Down Expand Up @@ -6793,11 +6793,12 @@ bool ldomXPointer::getRect(lvRect & rect, bool extended, bool adjusted) const
}
else {
bestBidiRect.left = word->x + rc.left + frmline->x;
if (extended)
if (extended) {
if (word->flags & LTEXT_WORD_IS_OBJECT && word->width > 0)
bestBidiRect.right = bestBidiRect.left + word->width; // width of image
else
bestBidiRect.right = bestBidiRect.left + 1;
}
}
hasBestBidiRect = true;
nearestForwardSrcIndex = word->src_text_index;
Expand Down Expand Up @@ -7007,13 +7008,15 @@ bool ldomXPointer::getRect(lvRect & rect, bool extended, bool adjusted) const
rect.left = word->x + rc.left + frmline->x;
//rect.top = word->y + rc.top + frmline->y + frmline->baseline;
rect.top = rc.top + frmline->y;
if (extended)
if (extended) {
if (word->flags & LTEXT_WORD_IS_OBJECT && word->width > 0)
rect.right = rect.left + word->width; // width of image
else
rect.right = rect.left + 1; // not the right word: no char width
else
}
else {
rect.right = rect.left + 1;
}
rect.bottom = rect.top + frmline->height;
return true;
} else if ( (offset < word->t.start+word->t.len)
Expand Down Expand Up @@ -10541,7 +10544,8 @@ void ldomDocumentWriterFilter::OnTagClose( const lChar16 * /*nsname*/, const lCh
lUInt16 id = _document->getElementNameIndex(tagname);

// HTML title detection
if ( id==el_title && _currNode->_element->getParentNode()!= NULL && _currNode->_element->getParentNode()->getNodeId()==el_head ) {
if ( id==el_title && _currNode && _currNode->_element && _currNode->_element->getParentNode()!= NULL
&& _currNode->_element->getParentNode()->getNodeId()==el_head ) {
lString16 s = _currNode->_element->getText();
s.trim();
if ( !s.empty() ) {
Expand Down

0 comments on commit 6ed9d00

Please sign in to comment.