0

使用:

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

Valgrindは言う:

==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== 

ここで初期化されていない値はどれだと思いますか?

コンストラクター:

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 ();
}

メンバー関数呼び出し:

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); }

アップデート:


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 ())

上記のようにコードを更新しましたが、エラーwrtが引き続き発生しますQTextEdit。Qt GUIからQTextEditを完全に削除すると、エラーは消えました。
ガイドしてください。

4

2 に答える 2

2

あなたがしているのは初期化ではなく、割り当てです。メンバー初期化リスト
を 確認してください。

于 2012-12-05T11:03:42.747 に答える
0

コードからわかることから、問題は Qt 自体にあります。QTextEdit だけを含む最小限のアプリケーションを作成し、同様のエラーが発生するかどうかを確認してください。はいの場合、それは Qt の問題であり、あなたの問題ではありません。エラーを抑制リストに追加する必要があります。

于 2012-12-05T18:04:23.257 に答える