Fix initialization of KReportDesign::Private::pageLayout (Qt bug) etc.
Closed, ResolvedPublic

Description

Default constructor of QPageLayout does not initialize units. We have Valgrind issues and possible crashes.

  • KReportDesign::Private::pageLayout
  • KReportDesignGlobal::defaultPageLayout
  • KReportDocument::Private::page
  • ORODocument::Private::pageLayout
  • local variable in KReportDesigner::pageWidthPx

https://bugreports.qt.io/browse/QTBUG-47551

Fixing it in Qt does not happen, and even if it happens, many Qt versions are not fixed anyway so we need a workaround.

Possible workaround: use another constructor of QPageLayout.

+add a comment that this is a workaround.

Valgrind check:

==16227==                                                                                                                                  
==16227== Conditional jump or move depends on uninitialised value(s)                                                                       
==16227==    at 0x6A00CAD: QPageSize::size(QPageSize::Unit) const (in /usr/lib64/libQt5Gui.so.5.6.1)                                       
==16227==    by 0x69FF26B: QPageLayout::setOrientation(QPageLayout::Orientation) (in /usr/lib64/libQt5Gui.so.5.6.1)                        
==16227==    by 0x40BC0D5: KReportDesigner::pageWidthPx() const (KReportDesigner.cpp:870)                                                  
==16227==    by 0x40BC2F5: KReportDesigner::resizeEvent(QResizeEvent*) (KReportDesigner.cpp:883)                                           
==16227==    by 0x602DA1E: QWidget::event(QEvent*) (in /usr/lib64/libQt5Widgets.so.5.6.1)                                                  
==16227==    by 0x5FEBF0B: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib64/libQt5Widgets.so.5.6.1)                    
==16227==    by 0x5FF0569: QApplication::notify(QObject*, QEvent*) (in /usr/lib64/libQt5Widgets.so.5.6.1)                                  
==16227==    by 0x71120B4: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib64/libQt5Core.so.5.6.1)                        
==16227==    by 0x6026BE1: QWidgetPrivate::sendPendingMoveAndResizeEvents(bool, bool) (in /usr/lib64/libQt5Widgets.so.5.6.1)               
==16227==    by 0x602A4A2: QWidgetPrivate::show_helper() (in /usr/lib64/libQt5Widgets.so.5.6.1)                                            
==16227==    by 0x602A3EE: QWidgetPrivate::showChildren(bool) (in /usr/lib64/libQt5Widgets.so.5.6.1)                                       
==16227==    by 0x602A4BE: QWidgetPrivate::show_helper() (in /usr/lib64/libQt5Widgets.so.5.6.1)
staniek created this task.Dec 22 2016, 10:05 PM
staniek renamed this task from Fix initialization of KReportDesign::Private::pageLayout (Qt bug) to Fix initialization of KReportDesign::Private::pageLayout (Qt bug) etc..Dec 22 2016, 10:12 PM
staniek updated the task description. (Show Details)
piggz added a subscriber: piggz.Jan 4 2017, 9:31 PM

It looks the the ctor that takes 5 arguments will correctly initilize all members, see https://github.com/qt/qtbase/blob/dev/src/gui/painting/qpagelayout.cpp

In T4968#73566, @piggz wrote:

It looks the the ctor that takes 5 arguments will correctly initilize all members, see https://github.com/qt/qtbase/blob/dev/src/gui/painting/qpagelayout.cpp

Yes exactly, and const QPageSize &pageSize, Orientation orientation, const QMarginsF &margins are the minimum.

@piggz One idea to have a temporary fix with minimal patch is to define an utility class KReportPageLayout : public QPageLayout with correct default ctor.

piggz closed this task as Resolved.May 12 2017, 9:05 PM
piggz claimed this task.