Commit eddbe031 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

enable clazy strict-iterators

parent e54609b5
......@@ -48,7 +48,7 @@ build_clazy_clang_tidy:
script:
- srcdir=`pwd` && mkdir -p /tmp/okular_build && cd /tmp/okular_build && CC=clang CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja $srcdir && cat compile_commands.json | jq '[.[] | select(.file | contains("'"$srcdir"'"))]' > compile_commands.aux.json && cat compile_commands.aux.json | jq '[.[] | select(.file | contains("/synctex/")| not)]' > compile_commands.json
- CLAZY_CHECKS="qstring-arg,incorrect-emit,qhash-namespace,detaching-temporary,range-loop,qdeleteall,connect-not-normalized,inefficient-qlist-soft" ninja
- CLAZY_CHECKS="qstring-arg,incorrect-emit,qhash-namespace,detaching-temporary,range-loop,qdeleteall,connect-not-normalized,inefficient-qlist-soft,strict-iterators" ninja
# Fix the poppler header, remove when debian:unstable ships poppler 0.82 or later
- sed -i "N;N;N;N; s#class MediaRendition\;\nclass MovieAnnotation\;\nclass ScreenAnnotation;#class MediaRendition\;#g" /usr/include/poppler/qt5/poppler-link.h
- "run-clang-tidy -header-filter='.*/okular/.*' -checks='-*,performance-*,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-make-unique,modernize-make-shared,modernize-use-override,modernize-use-equals-delete,modernize-use-emplace,modernize-loop-convert,modernize-use-nullptr,-bugprone-macro-parentheses,-bugprone-narrowing-conversions,-bugprone-branch-clone,-bugprone-incorrect-roundings' -config=\"{WarningsAsErrors: '*'}\""
......@@ -1311,7 +1311,8 @@ void DocumentPrivate::saveDocumentInfo() const
rotationNode.appendChild( doc.createTextNode( QString::number( (int)m_rotation ) ) );
}
// <general info><history> ... </history> save history up to OKULAR_HISTORY_SAVEDSTEPS viewports
QLinkedList< DocumentViewport >::const_iterator backIterator = m_viewportIterator;
const auto currentViewportIterator = QLinkedList< DocumentViewport >::const_iterator(m_viewportIterator);
QLinkedList< DocumentViewport >::const_iterator backIterator = currentViewportIterator;
if ( backIterator != m_viewportHistory.constEnd() )
{
// go back up to OKULAR_HISTORY_SAVEDSTEPS steps from the current viewportIterator
......@@ -1324,11 +1325,11 @@ void DocumentPrivate::saveDocumentInfo() const
generalInfo.appendChild( historyNode );
// add old[backIterator] and present[viewportIterator] items
QLinkedList< DocumentViewport >::const_iterator endIt = m_viewportIterator;
QLinkedList< DocumentViewport >::const_iterator endIt = currentViewportIterator;
++endIt;
while ( backIterator != endIt )
{
QString name = (backIterator == m_viewportIterator) ? QStringLiteral ("current") : QStringLiteral ("oldPage");
QString name = (backIterator == currentViewportIterator) ? QStringLiteral ("current") : QStringLiteral ("oldPage");
QDomElement historyEntry = doc.createElement( name );
historyEntry.setAttribute( QStringLiteral("viewport"), (*backIterator).toString() );
historyNode.appendChild( historyEntry );
......@@ -3871,9 +3872,9 @@ void Document::setPrevViewport()
void Document::setNextViewport()
// restore next viewport from the history
{
QLinkedList< DocumentViewport >::const_iterator nextIterator = d->m_viewportIterator;
auto nextIterator = QLinkedList< DocumentViewport >::const_iterator(d->m_viewportIterator);
++nextIterator;
if ( nextIterator != d->m_viewportHistory.end() )
if ( nextIterator != d->m_viewportHistory.constEnd() )
{
const int oldViewportPage = (*d->m_viewportIterator).pageNumber;
......
......@@ -406,15 +406,13 @@ void PagePrivate::rotateAt( Rotation orientation )
* Rotate the object rects on the page.
*/
const QTransform matrix = rotationMatrix();
QLinkedList< ObjectRect * >::const_iterator objectIt = m_page->m_rects.begin(), end = m_page->m_rects.end();
for ( ; objectIt != end; ++objectIt )
(*objectIt)->transform( matrix );
for ( ObjectRect *objRect : qAsConst(m_page->m_rects) )
objRect->transform( matrix );
const QTransform highlightRotationMatrix = Okular::buildRotationMatrix( (Rotation)(((int)m_rotation - (int)oldRotation + 4) % 4) );
QLinkedList< HighlightAreaRect* >::const_iterator hlIt = m_page->m_highlights.begin(), hlItEnd = m_page->m_highlights.end();
for ( ; hlIt != hlItEnd; ++hlIt )
for ( HighlightAreaRect *hlar : qAsConst(m_page->m_highlights) )
{
(*hlIt)->transform( highlightRotationMatrix );
hlar->transform( highlightRotationMatrix );
}
}
......@@ -736,10 +734,9 @@ void Page::setFormFields( const QLinkedList< FormField * >& fields )
{
qDeleteAll( d->formfields );
d->formfields = fields;
QLinkedList< FormField * >::const_iterator it = d->formfields.begin(), itEnd = d->formfields.end();
for ( ; it != itEnd; ++it )
for ( FormField *ff : qAsConst(d->formfields) )
{
(*it)->d_ptr->setDefault();
ff->d_ptr->setDefault();
}
}
......@@ -813,9 +810,7 @@ void Page::deleteAnnotations()
// delete ObjectRects of type Annotation
deleteObjectRects( m_rects, QSet<ObjectRect::ObjectType>() << ObjectRect::OAnnotation );
// delete all stored annotations
QLinkedList< Annotation * >::const_iterator aIt = m_annotations.begin(), aEnd = m_annotations.end();
for ( ; aIt != aEnd; ++aIt )
delete *aIt;
qDeleteAll( m_annotations );
m_annotations.clear();
}
......@@ -877,10 +872,9 @@ bool PagePrivate::restoreLocalContents( const QDomNode & pageNode )
continue;
QHash<int, FormField*> hashedforms;
QLinkedList< FormField * >::const_iterator fIt = formfields.begin(), fItEnd = formfields.end();
for ( ; fIt != fItEnd; ++fIt )
for ( FormField *ff : qAsConst(formfields) )
{
hashedforms[(*fIt)->id()] = (*fIt);
hashedforms[ff->id()] = ff;
}
// iterate over all forms
......
......@@ -602,7 +602,7 @@ void PageViewToolBar::selectButton( int id )
button = *(d->buttons.begin() + id);
else
{
QLinkedList< ToolBarButton * >::const_iterator it = d->buttons.begin(), end = d->buttons.end();
QLinkedList< ToolBarButton * >::const_iterator it = d->buttons.constBegin(), end = d->buttons.constEnd();
for ( ; !button && it != end; ++it )
if ( (*it)->isChecked() )
button = *it;
......@@ -797,7 +797,7 @@ void ToolBarPrivate::buildToolBar()
// 6. reposition buttons (in rows/col grid)
int gridX = 0,
gridY = 0;
QLinkedList< ToolBarButton * >::const_iterator it = buttons.begin(), end = buttons.end();
QLinkedList< ToolBarButton * >::const_iterator it = buttons.constBegin(), end = buttons.constEnd();
for ( ; it != end; ++it )
{
ToolBarButton * button = *it;
......@@ -832,7 +832,7 @@ void ToolBarPrivate::reposition()
q->move( currentPosition );
// repaint all buttons (to update background)
QLinkedList< ToolBarButton * >::const_iterator it = buttons.begin(), end = buttons.end();
QLinkedList< ToolBarButton * >::const_iterator it = buttons.constBegin(), end = buttons.constEnd();
for ( ; it != end; ++it )
(*it)->update();
}
......@@ -921,7 +921,7 @@ void ToolBarPrivate::selectButton( ToolBarButton * button )
if ( button )
{
// deselect other buttons
QLinkedList< ToolBarButton * >::const_iterator it = buttons.begin(), end = buttons.end();
QLinkedList< ToolBarButton * >::const_iterator it = buttons.constBegin(), end = buttons.constEnd();
for ( ; it != end; ++it )
if ( *it != button )
(*it)->setChecked( false );
......@@ -932,14 +932,14 @@ void ToolBarPrivate::selectButton( ToolBarButton * button )
void PageViewToolBar::setToolsEnabled( bool on )
{
QLinkedList< ToolBarButton * >::const_iterator it = d->buttons.begin(), end = d->buttons.end();
QLinkedList< ToolBarButton * >::const_iterator it = d->buttons.constBegin(), end = d->buttons.constEnd();
for ( ; it != end; ++it )
(*it)->setEnabled( on );
}
void PageViewToolBar::setTextToolsEnabled( bool on )
{
QLinkedList< ToolBarButton * >::const_iterator it = d->buttons.begin(), end = d->buttons.end();
QLinkedList< ToolBarButton * >::const_iterator it = d->buttons.constBegin(), end = d->buttons.constEnd();
for ( ; it != end; ++it )
if ( (*it)->isText() )
(*it)->setEnabled( on );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment