CI: Enable clazy qstring-arg check

remotes/origin/work/2004_421508
Albert Astals Cid 6 years ago
parent 5ecbb51f77
commit 96f00a4d29
  1. 6
      .gitlab-ci.yml
  2. 2
      autotests/kjsfunctionstest.cpp
  3. 2
      autotests/modifyannotationpropertiestest.cpp
  4. 8
      autotests/parttest.cpp
  5. 3
      core/script/kjs_event.cpp
  6. 5
      core/script/kjs_util.cpp
  7. 18
      generators/chm/lib/ebook_chm.cpp
  8. 2
      generators/dvi/TeXFont_PFB.cpp
  9. 12
      generators/dvi/TeXFont_PK.cpp
  10. 2
      generators/dvi/fontpool.cpp
  11. 18
      generators/fax/faxdocument.cpp
  12. 13
      generators/poppler/CMakeLists.txt
  13. 4
      generators/tiff/generator_tiff.cpp
  14. 2
      shell/shellutils.cpp
  15. 2
      ui/guiutils.cpp
  16. 4
      ui/pagepainter.cpp
  17. 4
      ui/presentationwidget.cpp

@ -44,11 +44,11 @@ build_clang_tidy:
- echo 'deb-src http://deb.debian.org/debian unstable main' >> /etc/apt/sources.list - echo 'deb-src http://deb.debian.org/debian unstable main' >> /etc/apt/sources.list
- apt-get update - apt-get update
- apt-get build-dep --yes --no-install-recommends okular - apt-get build-dep --yes --no-install-recommends okular
- apt-get install --yes --no-install-recommends ninja-build clang clang-tidy python python-yaml libkf5crash-dev libkf5purpose-dev libegl-dev jq - apt-get install --yes --no-install-recommends ninja-build clazy clang clang-tidy python python-yaml libkf5crash-dev libkf5purpose-dev libegl-dev jq
script: script:
- srcdir=`pwd` && mkdir -p /tmp/okular_build && cd /tmp/okular_build && CC=clang CXX=clang++ 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 - 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
- ninja - CLAZY_CHECKS="qstring-arg" ninja
# Fix the poppler header, remove when debian:unstable ships poppler 0.82 or later # 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 - 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: '*'}\"" - "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: '*'}\""

@ -91,10 +91,10 @@ private slots:
void testAlert(); void testAlert();
void testPrintD(); void testPrintD();
void testPrintD_data(); void testPrintD_data();
#endif
private: private:
Okular::Document *m_document; Okular::Document *m_document;
QMap<QString, Okular::FormField*> m_fields; QMap<QString, Okular::FormField*> m_fields;
#endif
}; };
#ifdef HAVE_POPPLER_0_79 #ifdef HAVE_POPPLER_0_79

@ -19,7 +19,7 @@
static const QColor RED = QColor(255, 0, 0); static const QColor RED = QColor(255, 0, 0);
static const QColor GREEN = QColor(0, 255, 0.0); static const QColor GREEN = QColor(0, 255, 0.0);
static const QColor BLUE = QColor(0, 0, 255); // static const QColor BLUE = QColor(0, 0, 255);
class ModifyAnnotationPropertiesTest : public QObject class ModifyAnnotationPropertiesTest : public QObject
{ {

@ -887,8 +887,8 @@ void PartTest::testSaveAs()
QString annotName; QString annotName;
QTemporaryFile archiveSave( QStringLiteral( "%1/okrXXXXXX.okular" ).arg( QDir::tempPath() ) ); QTemporaryFile archiveSave( QStringLiteral( "%1/okrXXXXXX.okular" ).arg( QDir::tempPath() ) );
QTemporaryFile nativeDirectSave( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); QTemporaryFile nativeDirectSave( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath(), extension ) );
QTemporaryFile nativeFromArchiveFile( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); QTemporaryFile nativeFromArchiveFile( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath(), extension ) );
QVERIFY( archiveSave.open() ); QVERIFY( archiveSave.open() );
archiveSave.close(); archiveSave.close();
QVERIFY( nativeDirectSave.open() ); QVERIFY( nativeDirectSave.open() );
@ -1071,10 +1071,10 @@ void PartTest::testSaveAsUndoStackAnnotations()
// when saving to a file format not supporting those. However, this button is only sensible // when saving to a file format not supporting those. However, this button is only sensible
// and available for "Save As", but not for "Save". By alternately saving to saveFile1 and // and available for "Save As", but not for "Save". By alternately saving to saveFile1 and
// saveFile2 we always force "Save As", so closeDialogHelper keeps working. // saveFile2 we always force "Save As", so closeDialogHelper keeps working.
QTemporaryFile saveFile1( QStringLiteral( "%1/okrXXXXXX_1.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); QTemporaryFile saveFile1( QStringLiteral( "%1/okrXXXXXX_1.%2" ).arg( QDir::tempPath(), extension ) );
QVERIFY( saveFile1.open() ); QVERIFY( saveFile1.open() );
saveFile1.close(); saveFile1.close();
QTemporaryFile saveFile2( QStringLiteral( "%1/okrXXXXXX_2.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); QTemporaryFile saveFile2( QStringLiteral( "%1/okrXXXXXX_2.%2" ).arg( QDir::tempPath(), extension ) );
QVERIFY( saveFile2.open() ); QVERIFY( saveFile2.open() );
saveFile2.close(); saveFile2.close();

@ -86,6 +86,9 @@ static KJSObject eventGetTarget( KJSContext *ctx, void *object )
return JSField::wrapField( ctx, target, event->targetPage() ); return JSField::wrapField( ctx, target, event->targetPage() );
break; break;
} }
default:
{
}
} }
return KJSUndefined(); return KJSUndefined();
} }

@ -104,9 +104,8 @@ static KJSObject printd( KJSContext *context, void *,
} }
QLocale locale( "en_US" ); QLocale locale( "en_US" );
QStringList str = arguments.at( 1 ).toString( context ).split( QRegularExpression( "\\W") ); const QStringList str = arguments.at( 1 ).toString( context ).split( QRegularExpression( "\\W") );
QString myStr = QStringLiteral( "%1/%2/%3 %4:%5:%6" ).arg( str[1] ). QString myStr = QStringLiteral( "%1/%2/%3 %4:%5:%6" ).arg( str[1], str[2], str[3], str[4], str[5], str[6] );
arg( str[2] ).arg( str[3] ).arg( str[4] ).arg( str[5] ).arg( str[6] );
QDateTime date = locale.toDateTime( myStr, QStringLiteral( "MMM/d/yyyy H:m:s" ) ); QDateTime date = locale.toDateTime( myStr, QStringLiteral( "MMM/d/yyyy H:m:s" ) );

@ -612,8 +612,8 @@ bool EBook_CHM::getInfoFromWindows()
if ( !RetrieveObject(&ui, buffer, 0, WIN_HEADER_LEN) ) if ( !RetrieveObject(&ui, buffer, 0, WIN_HEADER_LEN) )
return false; return false;
unsigned int entries = get_int32_le( (unsigned int *)(buffer) ); unsigned int entries = get_int32_le( reinterpret_cast<unsigned int *>(buffer) );
unsigned int entry_size = get_int32_le( (unsigned int *)(buffer + 0x04) ); unsigned int entry_size = get_int32_le( reinterpret_cast<unsigned int *>(buffer + 0x04) );
QVector<unsigned char> uptr(entries * entry_size); QVector<unsigned char> uptr(entries * entry_size);
unsigned char* raw = (unsigned char*) uptr.data(); unsigned char* raw = (unsigned char*) uptr.data();
@ -628,10 +628,10 @@ bool EBook_CHM::getInfoFromWindows()
{ {
unsigned int offset = i * entry_size; unsigned int offset = i * entry_size;
unsigned int off_title = get_int32_le( (unsigned int *)(raw + offset + 0x14) ); unsigned int off_title = get_int32_le( reinterpret_cast<unsigned int *>(raw + offset + 0x14) );
unsigned int off_home = get_int32_le( (unsigned int *)(raw + offset + 0x68) ); unsigned int off_home = get_int32_le( reinterpret_cast<unsigned int *>(raw + offset + 0x68) );
unsigned int off_hhc = get_int32_le( (unsigned int *)(raw + offset + 0x60) ); unsigned int off_hhc = get_int32_le( reinterpret_cast<unsigned int *>(raw + offset + 0x60) );
unsigned int off_hhk = get_int32_le( (unsigned int *)(raw + offset + 0x64) ); unsigned int off_hhk = get_int32_le( reinterpret_cast<unsigned int *>(raw + offset + 0x64) );
factor = off_title / 4096; factor = off_title / 4096;
@ -901,9 +901,9 @@ void EBook_CHM::fillTopicsUrlMap()
for ( LONGUINT64 i = 0; i < m_chmTOPICS.length; i += TOPICS_ENTRY_LEN ) for ( LONGUINT64 i = 0; i < m_chmTOPICS.length; i += TOPICS_ENTRY_LEN )
{ {
unsigned int off_title = get_int32_le( (unsigned int *)(topics.data() + i + 4) ); unsigned int off_title = get_int32_le( reinterpret_cast<unsigned int *>(topics.data() + i + 4) );
unsigned int off_url = get_int32_le( (unsigned int *)(topics.data() + i + 8) ); unsigned int off_url = get_int32_le( reinterpret_cast<unsigned int *>(topics.data() + i + 8) );
off_url = get_int32_le( (unsigned int *)( urltbl.data() + off_url + 8) ) + 8; off_url = get_int32_le( reinterpret_cast<unsigned int *>( urltbl.data() + off_url + 8) ) + 8;
QUrl url = pathToUrl( (const char*) urlstr.data() + off_url ); QUrl url = pathToUrl( (const char*) urlstr.data() + off_url );

@ -253,7 +253,7 @@ glyph* TeXFont_PFB::getGlyph(quint16 ch, bool generateCharacterPixmap, const QCo
for(unsigned int y=0; y<slot->bitmap.rows; y++) { for(unsigned int y=0; y<slot->bitmap.rows; y++) {
quint8 *srcScanLine = slot->bitmap.buffer + y*slot->bitmap.pitch; quint8 *srcScanLine = slot->bitmap.buffer + y*slot->bitmap.pitch;
unsigned int *destScanLine = (unsigned int *)imgi.scanLine(y); unsigned int *destScanLine = reinterpret_cast<unsigned int *>(imgi.scanLine(y));
for(unsigned int col=0; col<slot->bitmap.width; col++) { for(unsigned int col=0; col<slot->bitmap.width; col++) {
quint16 data = *srcScanLine; quint16 data = *srcScanLine;
// The value stored in "data" now has the following meaning: // The value stored in "data" now has the following meaning:

@ -295,7 +295,7 @@ glyph* TeXFont_PK::getGlyph(quint16 ch, bool generateCharacterPixmap, const QCol
quint8 *srcScanLine = xydata; quint8 *srcScanLine = xydata;
for(int y=0; y<shrunk_height; y++) { for(int y=0; y<shrunk_height; y++) {
unsigned int *destScanLine = (unsigned int *)im32.scanLine(y); unsigned int *destScanLine = reinterpret_cast<unsigned int *>(im32.scanLine(y));
for(int col=0; col<shrunk_width; col++) { for(int col=0; col<shrunk_width; col++) {
quint16 data = *srcScanLine; quint16 data = *srcScanLine;
// The value stored in "data" now has the following meaning: // The value stored in "data" now has the following meaning:
@ -317,8 +317,8 @@ glyph* TeXFont_PK::getGlyph(quint16 ch, bool generateCharacterPixmap, const QCol
#define ADD(a, b) ((quint32 *) (((char *) a) + b)) #define ADD(a, b) (reinterpret_cast<quint32 *>(((char *) a) + b))
#define SUB(a, b) ((quint32 *) (((char *) a) - b)) #define SUB(a, b) (reinterpret_cast<quint32 *>(((char *) a) - b))
@ -534,7 +534,7 @@ void TeXFont_PK::read_PK_char(unsigned int ch)
characterBitmaps[ch]->bits = new char[size != 0 ? size : 1]; characterBitmaps[ch]->bits = new char[size != 0 ? size : 1];
} }
cp = (quint32 *) characterBitmaps[ch]->bits; cp = reinterpret_cast<quint32 *>(characterBitmaps[ch]->bits);
/* /*
* read character data into *cp * read character data into *cp
@ -618,7 +618,7 @@ void TeXFont_PK::read_PK_char(unsigned int ch)
} }
paint_switch = 1 - paint_switch; paint_switch = 1 - paint_switch;
} }
if (cp != ((quint32 *) (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h))) if (cp != (reinterpret_cast<quint32 *> (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h)))
oops(i18n("Wrong number of bits stored: char. %1, font %2", ch, parent->filename)); oops(i18n("Wrong number of bits stored: char. %1, font %2", ch, parent->filename));
if (rows_left != 0 || h_bit != characterBitmaps[ch]->w) if (rows_left != 0 || h_bit != characterBitmaps[ch]->w)
oops(i18n("Bad pk file (%1), too many bits", parent->filename)); oops(i18n("Bad pk file (%1), too many bits", parent->filename));
@ -704,7 +704,7 @@ void TeXFont_PK::read_PK_char(unsigned int ch)
} }
paint_switch = 1 - paint_switch; paint_switch = 1 - paint_switch;
} }
if (cp != ((quint32 *) (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h))) if (cp != (reinterpret_cast<quint32 *> (characterBitmaps[ch]->bits + bytes_wide * characterBitmaps[ch]->h)))
oops(i18n("Wrong number of bits stored: char. %1, font %2", ch, parent->filename)); oops(i18n("Wrong number of bits stored: char. %1, font %2", ch, parent->filename));
if (rows_left != 0 || h_bit != characterBitmaps[ch]->w) if (rows_left != 0 || h_bit != characterBitmaps[ch]->w)
oops(i18n("Bad pk file (%1), too many bits", parent->filename)); oops(i18n("Bad pk file (%1), too many bits", parent->filename));

@ -61,7 +61,7 @@ fontPool::fontPool(bool useFontHinting)
// extension, alpha channels are either supported, or silently // extension, alpha channels are either supported, or silently
// ignored. // ignored.
QImage start(1, 1, QImage::Format_ARGB32); // Generate a 1x1 image, black with alpha=0x10 QImage start(1, 1, QImage::Format_ARGB32); // Generate a 1x1 image, black with alpha=0x10
quint32 *destScanLine = (quint32 *)start.scanLine(0); quint32 *destScanLine = reinterpret_cast<quint32 *>(start.scanLine(0));
*destScanLine = 0x80000000; *destScanLine = 0x80000000;
QPixmap intermediate = QPixmap::fromImage(start); QPixmap intermediate = QPixmap::fromImage(start);
QPixmap dest(1,1); QPixmap dest(1,1);

@ -22,7 +22,7 @@ static const char FAXMAGIC[] = "\000PC Research, Inc\000\000\000\000\000\000";
/* rearrange input bits into t16bits lsb-first chunks */ /* rearrange input bits into t16bits lsb-first chunks */
static void normalize( pagenode *pn, int revbits, int swapbytes, size_t length ) static void normalize( pagenode *pn, int revbits, int swapbytes, size_t length )
{ {
t32bits *p = (t32bits *) pn->data; t32bits *p = reinterpret_cast<t32bits *>( pn->data );
switch ( (revbits<<1) | swapbytes ) switch ( (revbits<<1) | swapbytes )
{ {
@ -101,8 +101,8 @@ static unsigned char* getstrip( pagenode *pn, int strip )
data = new uchar[ roundup ]; data = new uchar[ roundup ];
/* clear the last 2 t32bits, to force the expander to terminate /* clear the last 2 t32bits, to force the expander to terminate
even if the file ends in the middle of a fax line */ even if the file ends in the middle of a fax line */
*((t32bits *) data + roundup/4 - 2) = 0; *(reinterpret_cast<t32bits*>( data + roundup/4 - 2)) = 0;
*((t32bits *) data + roundup/4 - 1) = 0; *(reinterpret_cast<t32bits*>( data + roundup/4 - 1)) = 0;
/* we expect to get it in one gulp... */ /* we expect to get it in one gulp... */
if ( !file.seek(offset) || (size_t) file.read( (char *)data, pn->length ) != pn->length ) if ( !file.seek(offset) || (size_t) file.read( (char *)data, pn->length ) != pn->length )
@ -112,7 +112,7 @@ static unsigned char* getstrip( pagenode *pn, int strip )
} }
file.close(); file.close();
pn->data = (t16bits *)data; pn->data = reinterpret_cast<t16bits *>(data);
if ( pn->strips == nullptr && memcmp( data, FAXMAGIC, sizeof( FAXMAGIC ) - 1 ) == 0 ) if ( pn->strips == nullptr && memcmp( data, FAXMAGIC, sizeof( FAXMAGIC ) - 1 ) == 0 )
{ {
@ -137,7 +137,7 @@ static unsigned char* getstrip( pagenode *pn, int strip )
if ( pn->strips == nullptr ) if ( pn->strips == nullptr )
pn->rowsperstrip = pn->size.height(); pn->rowsperstrip = pn->size.height();
pn->dataOrig = (t16bits *)data; pn->dataOrig = reinterpret_cast<t16bits *>(data);
return data; return data;
} }
@ -156,8 +156,8 @@ static void draw_line( pixnum *run, int lineNum, pagenode *pn )
if ( lineNum >= pn->size.height() ) if ( lineNum >= pn->size.height() )
return; return;
p = (t32bits *)(pn->imageData + lineNum*(2-pn->vres)*pn->bytes_per_line); p = reinterpret_cast<t32bits*>(pn->imageData + lineNum*(2-pn->vres)*pn->bytes_per_line);
p1 =(t32bits *)(pn->vres ? nullptr : p + pn->bytes_per_line/sizeof(*p)); p1 =reinterpret_cast<t32bits*>(pn->vres ? nullptr : p + pn->bytes_per_line/sizeof(*p));
r = run; r = run;
acc = 0; acc = 0;
@ -277,8 +277,8 @@ bool FaxDocument::load()
for ( int y= height - 1; y >= 0; --y ) for ( int y= height - 1; y >= 0; --y )
{ {
quint32 offset = y * bytes_per_line; quint32 offset = y * bytes_per_line;
quint32 *source = (quint32 *) (d->mPageNode.imageData + offset); quint32 *source = reinterpret_cast<quint32 *> (d->mPageNode.imageData + offset);
quint32 *dest = (quint32 *) (bytes.data() + offset); quint32 *dest = reinterpret_cast<quint32 *> (bytes.data() + offset);
for ( int x= (bytes_per_line/4) - 1; x >= 0; --x ) for ( int x= (bytes_per_line/4) - 1; x >= 0; --x )
{ {
quint32 dv = 0, sv = *source; quint32 dv = 0, sv = *source;

@ -10,7 +10,7 @@ check_cxx_source_compiles("
#include <QImage> #include <QImage>
int main() int main()
{ {
Poppler::Page *p; Poppler::Page *p = nullptr;
p->renderToImage(0, 0, 0, 0, 0, 0, Poppler::Page::Rotate0, nullptr, nullptr, nullptr, QVariant()); p->renderToImage(0, 0, 0, 0, 0, 0, Poppler::Page::Rotate0, nullptr, nullptr, nullptr, QVariant());
return 0; return 0;
} }
@ -22,10 +22,10 @@ check_cxx_source_compiles("
#include <poppler-link.h> #include <poppler-link.h>
int main() int main()
{ {
Poppler::FormField *f; Poppler::FormField *f = nullptr;
f->setReadOnly(true); f->setReadOnly(true);
f->setVisible(true); f->setVisible(true);
Poppler::Link *l; Poppler::Link *l = nullptr;
l->nextLinks(); l->nextLinks();
} }
" HAVE_POPPLER_0_64) " HAVE_POPPLER_0_64)
@ -35,7 +35,7 @@ check_cxx_source_compiles("
#include <poppler-form.h> #include <poppler-form.h>
int main() int main()
{ {
Poppler::FormField *f; Poppler::FormField *f = nullptr;
f->additionalAction(Poppler::Annotation::CursorEnteringAction); f->additionalAction(Poppler::Annotation::CursorEnteringAction);
} }
" HAVE_POPPLER_0_65) " HAVE_POPPLER_0_65)
@ -46,6 +46,7 @@ check_cxx_source_compiles("
int main() int main()
{ {
auto f = &Poppler::SignatureValidationInfo::reason; auto f = &Poppler::SignatureValidationInfo::reason;
(void)f;
} }
" HAVE_POPPLER_0_68) " HAVE_POPPLER_0_68)
@ -65,6 +66,7 @@ check_cxx_source_compiles("
int main() int main()
{ {
QString s = Poppler::Version::string(); QString s = Poppler::Version::string();
(void)s;
return 0; return 0;
} }
" HAVE_POPPLER_0_73) " HAVE_POPPLER_0_73)
@ -75,7 +77,7 @@ check_cxx_source_compiles("
int main() int main()
{ {
Poppler::FormFieldIcon icon(nullptr); Poppler::FormFieldIcon icon(nullptr);
Poppler::FormFieldButton *button; Poppler::FormFieldButton *button = nullptr;
button->setIcon( icon ); button->setIcon( icon );
return 0; return 0;
} }
@ -87,6 +89,7 @@ int main()
{ {
Poppler::FontInfo info; Poppler::FontInfo info;
QString substituteName = info.substituteName(); QString substituteName = info.substituteName();
(void)substituteName;
return 0; return 0;
} }
" HAVE_POPPLER_0_80) " HAVE_POPPLER_0_80)

@ -251,7 +251,7 @@ QImage TIFFGenerator::image( Okular::PixmapRequest * request )
orientation = ORIENTATION_TOPLEFT; orientation = ORIENTATION_TOPLEFT;
QImage image( width, height, QImage::Format_RGB32 ); QImage image( width, height, QImage::Format_RGB32 );
uint32 * data = (uint32 *)image.bits(); uint32 * data = reinterpret_cast<uint32 *>(image.bits());
// read data // read data
if ( TIFFReadRGBAImageOriented( d->tiff, width, height, data, orientation ) != 0 ) if ( TIFFReadRGBAImageOriented( d->tiff, width, height, data, orientation ) != 0 )
@ -389,7 +389,7 @@ bool TIFFGenerator::print( QPrinter& printer )
continue; continue;
QImage image( width, height, QImage::Format_RGB32 ); QImage image( width, height, QImage::Format_RGB32 );
uint32 * data = (uint32 *)image.bits(); uint32 * data = reinterpret_cast<uint32 *>(image.bits());
// read data // read data
if ( TIFFReadRGBAImageOriented( d->tiff, width, height, data, ORIENTATION_TOPLEFT ) != 0 ) if ( TIFFReadRGBAImageOriented( d->tiff, width, height, data, ORIENTATION_TOPLEFT ) != 0 )

@ -77,7 +77,7 @@ QString serializeOptions(const QCommandLineParser &args)
QString serializeOptions(bool startInPresentation, bool showPrintDialog, bool showPrintDialogAndExit, bool unique, bool noRaise, const QString &page, const QString &find) QString serializeOptions(bool startInPresentation, bool showPrintDialog, bool showPrintDialogAndExit, bool unique, bool noRaise, const QString &page, const QString &find)
{ {
return QStringLiteral("%1:%2:%3:%4:%5:%6:%7").arg(startInPresentation).arg(showPrintDialog).arg(showPrintDialogAndExit).arg(unique).arg(noRaise).arg(page).arg(QString(find.toLatin1().toBase64())); return QStringLiteral("%1:%2:%3:%4:%5:%6:%7").arg(startInPresentation).arg(showPrintDialog).arg(showPrintDialogAndExit).arg(unique).arg(noRaise).arg(page, QString::fromLatin1(find.toLatin1().toBase64()));
} }
bool unserializeOptions(const QString &serializedOptions, bool *presentation, bool *print, bool *print_and_exit, bool *unique, bool *noraise, QString *page, QString *find) bool unserializeOptions(const QString &serializedOptions, bool *presentation, bool *print, bool *print_and_exit, bool *unique, bool *noraise, QString *page, QString *find)

@ -269,7 +269,7 @@ void colorizeImage( QImage & grayImage, const QColor & color, unsigned int destA
grayImage = grayImage.convertToFormat( QImage::Format_ARGB32_Premultiplied ); grayImage = grayImage.convertToFormat( QImage::Format_ARGB32_Premultiplied );
// iterate over all pixels changing the alpha component value // iterate over all pixels changing the alpha component value
unsigned int * data = (unsigned int *)grayImage.bits(); unsigned int * data = reinterpret_cast<unsigned int *>(grayImage.bits());
unsigned int pixels = grayImage.width() * grayImage.height(); unsigned int pixels = grayImage.width() * grayImage.height();
int red = color.red(), int red = color.red(),
green = color.green(), green = color.green(),

@ -372,7 +372,7 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
break; break;
case Okular::SettingsCore::EnumRenderMode::BlackWhite: case Okular::SettingsCore::EnumRenderMode::BlackWhite:
// Manual Gray and Contrast // Manual Gray and Contrast
unsigned int * data = (unsigned int *)backImage.bits(); unsigned int * data = reinterpret_cast<unsigned int *>(backImage.bits());
int val, pixels = backImage.width() * backImage.height(), int val, pixels = backImage.width() * backImage.height(),
con = Okular::Settings::bWContrast(), thr = 255 - Okular::Settings::bWThreshold(); con = Okular::Settings::bWContrast(), thr = 255 - Okular::Settings::bWThreshold();
for( int i = 0; i < pixels; ++i ) for( int i = 0; i < pixels; ++i )
@ -850,7 +850,7 @@ static inline int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; }
void PagePainter::changeImageAlpha( QImage & image, unsigned int destAlpha ) void PagePainter::changeImageAlpha( QImage & image, unsigned int destAlpha )
{ {
// iterate over all pixels changing the alpha component value // iterate over all pixels changing the alpha component value
unsigned int * data = (unsigned int *)image.bits(); unsigned int * data = reinterpret_cast<unsigned int *>(image.bits());
unsigned int pixels = image.width() * image.height(); unsigned int pixels = image.width() * image.height();
int source, sourceAlpha; int source, sourceAlpha;

@ -1302,8 +1302,8 @@ void PresentationWidget::generateOverlay()
color = pal.color( QPalette::Active, QPalette::Highlight ); color = pal.color( QPalette::Active, QPalette::Highlight );
int sRed = color.red(), sGreen = color.green(), sBlue = color.blue(); int sRed = color.red(), sGreen = color.green(), sBlue = color.blue();
// pointers // pointers
unsigned int * data = (unsigned int *)image.bits(), unsigned int * data = reinterpret_cast<unsigned int *>(image.bits()),
* shadowData = (unsigned int *)shadow.bits(), * shadowData = reinterpret_cast<unsigned int *>(shadow.bits()),
pixels = image.width() * image.height(); pixels = image.width() * image.height();
// cache data (reduce computation time to 26%!) // cache data (reduce computation time to 26%!)
int c1 = -1, c2 = -1, cR = 0, cG = 0, cB = 0, cA = 0; int c1 = -1, c2 = -1, cR = 0, cG = 0, cB = 0, cA = 0;

Loading…
Cancel
Save