0

Using:

valgrind --leak-check=full -v --fullpath-after=. --num-callers=50 --track-origins=yes --leak-resolution=high offline

Valgrind says:

==8914== Conditional jump or move depends on uninitialised value(s)
==8914==    at 0x62E9ADD: QTextFormatCollection::indexForFormat(QTextFormat const&) (/var/tmp/qt-src/src/gui/text/qtextformat.cpp:3075)
==8914==    by 0x6301D65: QTextDocumentPrivate::init() (/var/tmp/qt-src/src/gui/text/qtextdocument_p.cpp:228)
==8914==    by 0x630350B: QTextDocumentPrivate::clear() (/var/tmp/qt-src/src/gui/text/qtextdocument_p.cpp:275)
==8914==    by 0x62F41E7: QTextDocument::setHtml(QString const&) (/var/tmp/qt-src/src/gui/text/qtextdocument.cpp:1186)
==8914==    by 0x62C123E: QTextControlPrivate::setContent(Qt::TextFormat, QString const&, QTextDocument*) (/var/tmp/qt-src/src/gui/text/qtextcontrol.cpp:481)
==8914==    by 0x64F4C8E: QTextEditPrivate::init(QString const&) (/var/tmp/qt-src/src/gui/widgets/qtextedit.cpp:174)
==8914==    by 0x64F5528: QTextEdit::QTextEdit(QString const&, QWidget*) (/var/tmp/qt-src/src/gui/widgets/qtextedit.cpp:625)
==8914==    by 0x40E1B3: controlRThroughQt::controlRThroughQt() (in /home/anisha/.../offline)
==8914==    by 0x40E933: main (in /home/anisha/.../offline)
==8914==  Uninitialised value was created by a stack allocation
==8914==    at 0x62E73B0: QTextFormatPrivate::recalcHash() const (/var/tmp/qt-src/src/gui/text/qtextformat.cpp:317)
==8914== 

Which values do you think are uninitialized here?

The constructor:

controlRThroughQt :: controlRThroughQt ()
{
    /** Qt widget's interface which will be controlling the R's widget */
    window          = new QMainWindow  ();
    centralWidget = new QWidget (window);

    refresh          = new QPushButton ("Start R", window);
    refresh->setFixedSize   (55, 55);
    connect (refresh, SIGNAL (clicked ()), this, SLOT (slotRefreshR ()));

    zoomIn          = new QPushButton ("Zoom\nin", window);
    zoomIn->setFixedSize   (55, 55);
    connect (zoomIn, SIGNAL (clicked ()), this, SLOT (slotZoomInR ()));

    zoomOut        = new QPushButton ("Zoom\nout", window);
    zoomOut->setFixedSize   (55, 55);
    connect (zoomOut, SIGNAL (clicked ()), this, SLOT (slotZoomOutR ()));

    panLeft          = new QPushButton ("Pan\nLeft", window);
    panLeft->setFixedSize   (55, 55);
    connect (panLeft, SIGNAL (clicked ()), this, SLOT (slotPanLeftR ()));

    panRight         = new QPushButton ("Pan\nRight", window);
    panRight->setFixedSize   (55, 55);
    connect (panRight, SIGNAL (clicked ()), this, SLOT (slotPanRightR ()));

    panTop          = new QPushButton ("Pan\nTop", window);
    panTop->setFixedSize   (55, 55);
    connect (panTop, SIGNAL (clicked ()), this, SLOT (slotPanTopR ()));

    panBottom      = new QPushButton ("Pan\nBottom", window);
    panBottom->setFixedSize   (55, 55);
    connect (panBottom, SIGNAL (clicked ()), this, SLOT (slotPanBottomR ()));

    panBottomRight = new QPushButton ("Bottom\nRight", window);
    panBottomRight->setFixedSize   (55, 55);
    connect (panBottomRight, SIGNAL (clicked ()), this, SLOT (slotPanBottomRightR ()));

    panBottomLeft   = new QPushButton ("Bottom\nLeft", window);
    panBottomLeft->setFixedSize   (55, 55);
    connect (panBottomLeft, SIGNAL (clicked ()), this, SLOT (slotPanBottomLeftR ()));

    panTopRight     = new QPushButton ("Top\nRight", window);
    panTopRight->setFixedSize   (55, 55);
    connect (panTopRight, SIGNAL (clicked ()), this, SLOT (slotPanTopRightR ()));

    panTopLeft      = new QPushButton ("Top\nLeft", window);
    panTopLeft->setFixedSize   (55, 55);
    connect (panTopLeft, SIGNAL (clicked ()), this, SLOT (slotPanTopLeftR ()));

    findInfo        = new QPushButton ("Find\nInfo.", window);
    findInfo->setFixedSize   (55, 55);
    connect (findInfo, SIGNAL (clicked ()), this, SLOT (slotFindInfoR ()));

    textEdit        = new QTextEdit ("Vehicle Info. will be shown here.", window);
    textEdit->setReadOnly (true);
    textEdit->setFixedSize (155, 555);

    layout          = new QGridLayout ();
    centralWidget->setLayout (layout);
    layout->addWidget (refresh, 0, 0);
    layout->addWidget (zoomIn, 1, 0);
    layout->addWidget (zoomOut, 1, 1);

    layout->addWidget (panLeft, 2, 0);
    layout->addWidget (panRight, 2, 1);
    layout->addWidget (panTop, 3, 0);
    layout->addWidget (panBottom, 3, 1);

    layout->addWidget (panBottomRight, 4, 0);
    layout->addWidget (panBottomLeft, 4, 1);
    layout->addWidget (panTopRight, 5, 0);
    layout->addWidget (panTopLeft, 5, 1);

    layout->addWidget (findInfo, 6, 0);
    layout->addWidget (textEdit, 7, 0);

    window->setCentralWidget (centralWidget);
    window->setWindowFlags (Qt::WindowStaysOnTopHint);
    window->show ();
}

Member function calls:

void controlRThroughQt :: slotRefreshR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (0, 0, 0); }

void controlRThroughQt :: slotPanLeftR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (1, 0, 0); }
void controlRThroughQt :: slotPanRightR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (2, 0, 0); }
void controlRThroughQt :: slotPanTopR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (3, 0, 0); }
void controlRThroughQt :: slotPanBottomR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (4, 0, 0); }

void controlRThroughQt :: slotPanTopLeftR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (5, 0, 0); }
void controlRThroughQt :: slotPanTopRightR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (6, 0, 0); }
void controlRThroughQt :: slotPanBottomLeftR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (7, 0, 0); }
void controlRThroughQt :: slotPanBottomRightR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (8, 0, 0); }

void controlRThroughQt :: slotZoomInR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (9, 0, 0); }
void controlRThroughQt :: slotZoomOutR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (10, 0, 0); }

void controlRThroughQt :: slotFindInfoR () { rdaTilesOnR :: loadNewTileAndPlotPointsOnRWidget (12, 0, 0); }

UPDATE:


controlRThroughQt :: controlRThroughQt () : 
                    window (new QMainWindow  ()),
                    centralWidget (new QWidget (window)),
                    refresh (new QPushButton ("Start R", window)), 
                    zoomIn (new QPushButton ("Zoom\nin", window)),
                    zoomOut (new QPushButton ("Zoom\nout", window)),
                    panLeft (new QPushButton ("Pan\nLeft", window)),
                    panRight (new QPushButton ("Pan\nRight", window)),
                    panTop (new QPushButton ("Pan\nTop", window)),
                    panBottom (new QPushButton ("Pan\nBottom", window)),
                    panBottomRight (new QPushButton ("Bottom\nRight", window)),
                    panBottomLeft (new QPushButton ("Bottom\nLeft", window)),
                    panTopRight (new QPushButton ("Top\nRight", window)),
                    panTopLeft (new QPushButton ("Top\nLeft", window)),
                    findInfo (new QPushButton ("Find\nInfo.", window)),
                    textEdit (new QTextEdit ("Vehicle Info.", window)),
                    layout (new QGridLayout ())

I updated my code as shown above, but the error w.r.t QTextEdit still persists. When I removed the QTextEdit totally from the Qt GUI, the error vanished.
Guide please.

Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411

2 Answers2

2

What you are doing is not initialization it is an assignment.
Check Member Initialization List.

Community
  • 1
  • 1
Alok Save
  • 202,538
  • 53
  • 430
  • 533
  • @AnishaKaul: Check inline link of my C++ Faq answer. – Alok Save Dec 05 '12 at 11:05
  • Als, I have noticed an observation and updated my question above. Please see and help. – Aquarius_Girl Dec 05 '12 at 12:37
  • 1
    @AnishaKaul: Note that order of initialization in member initializer list is the *order in which the members are declared* not the order you specify in the init list.So as long as `window` is declared before `textEdit` it should be okay.On a side note a quick google search shows lot of similar uninitialized value problems for `QTextFormatCollection::indexForFormat()`, it is very much possible that the root cause lies in the QT framework code itself.You might want to create a simplistic example and check it with valgrind to verify this & submit a bug on QT if you can reproduce it. – Alok Save Dec 06 '12 at 03:15
0

From what I can tell from the code, the problem is within Qt itself. Write a minimal application with just a QTextEdit in it and see whether you can get a similar error. If yes, it's Qt's problem, not yours, and you should add the error to a suppression list.

Nikos C.
  • 50,738
  • 9
  • 71
  • 96