Skip to content

Avoid 'conversion may change value' cases in listpanel.cpp and krlayoutfactory.cpp

Toni Asensi Esteve requested to merge work/conversion_listpanel_lf into master

Avoid three warnings in listpanel.cpp and krlayoutfactory.cpp, confirming the conversions to int because three Qt functions that are used (setValue(int value), qUncompress(const uchar *data, int nbytes) and QByteArray(const char *data, int size)) only accept int arguments.

The warnings are:

    /home/user/krusader/krusader/Panel/listpanel.cpp:1013: warning: conversion from ‘long unsigned int’ to ‘int’ may change value [-Wconversion]
    /home/user/krusader/krusader/Panel/listpanel.cpp: In member function ‘void ListPanel::slotPreviewJobPercent(KJob*, long unsigned int)’:
    /home/user/krusader/krusader/Panel/listpanel.cpp:1013:31: warning: conversion from ‘long unsigned int’ to ‘int’ may change value [-Wconversion]
    1013 |     previewProgress->setValue(percent);
         |                               ^~~~~~~    

    /home/user/krusader/krusader/Panel/krlayoutfactory.cpp:96: warning: conversion from ‘qint64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]
    /home/user/krusader/krusader/Panel/krlayoutfactory.cpp: In static member function ‘static bool KrLayoutFactory::parseResource(const QString&, QDomDocument&)’:
    /home/user/krusader/krusader/Panel/krlayoutfactory.cpp:96:52: warning: conversion from ‘qint64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]
    96 |             data = qUncompress(res.data(), res.size());
       |                                            ~~~~~~~~^~        

    /home/user/krusader/krusader/Panel/krlayoutfactory.cpp:98: warning: conversion from ‘qint64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]
    /home/user/krusader/krusader/Panel/krlayoutfactory.cpp:98:82: warning: conversion from ‘qint64’ {aka ‘long long int’} to ‘int’ may change value [-Wconversion]
    98 |             data = QByteArray(reinterpret_cast<const char*>(res.data()), res.size());
       |                                                                          ~~~~~~~~^~            

TEST PLAN

The behaviour of Krusader should not change after applying the proposed changes. Anyway, if anyone wants to perform some tests:

  • Go to the View menu and enable Show Previews, enter a folder with a lot of big (and previewable) files, check that the percentage of the progress indicator (it's seen on the right of the text "loading previews") is seen correctly.
  • Perform more operations with Krusader panels, check that they work correctly when their layouts are changed, go to the View menu and select Brief View, select Detailed View afterwards, etc.

Merge request reports