Correct Suppression Valgrind : Fedora 14 i686
-
I have the following code (see below so my questions is not lost in the code).
Now I want to start things off correct, so I am first just following some examples and trying to make sure I can do memory leak checks on my code. So I followed the subsequent tutorials to do that:
"http://www.developer.nokia.com/Community/Wiki/Using_valgrind_with_Qt_Creator":http://www.developer.nokia.com/Community/Wiki/Using_valgrind_with_Qt_Creator
and
"http://doc.qt.nokia.com/qtcreator-snapshot/creator-analyzer.html":http://doc.qt.nokia.com/qtcreator-snapshot/creator-analyzer.html
Now I know I have to write a suppression file to take care of the "leaks" that come from xlib, cairo, etc. However, when I add the suppression file to my project and then run the analyzer I am still getting massive leaks reported.
Please note that I am aware that Qt manages deleting children widgets, and that a destructor really is not necessary below. I placed them in there just to guarantee that every thing in my code is removed.
Also at the very bottom of the post is a small clip from the leaks reported.
Here is my suppression file:
@{
<insert_a_suppression_name_here>
Memcheck:Cond
fun:_ZN20QSharedMemoryPrivate6detachEv
fun:_ZN13QSharedMemory6detachEv
fun:_ZN13QSharedMemory6setKeyERK7QString
fun:_ZN13QSharedMemoryD1Ev
fun:_ZN20QRasterWindowSurface5flushEP7QWidgetRK7QRegionRK6QPoint
fun:_Z8qt_flushP7QWidgetRK7QRegionP14QWindowSurfaceS0_RK6QPoint
fun:_ZN19QWidgetBackingStore5flushEP7QWidgetP14QWindowSurface
fun:_ZN19QWidgetBackingStore8endPaintERK7QRegionP14QWindowSurfaceP14BeginPaintInfo
fun:_ZN19QWidgetBackingStore4syncEv
fun:_ZN14QWidgetPrivate16syncBackingStoreEv
fun:_ZN7QWidget5eventEP6QEvent
fun:_ZN11QMainWindow5eventEP6QEvent
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
fun:_Znwm
fun:_ZN18QtSimulatorPrivate15connectToServerEv
fun:_ZN18QtSimulatorPrivate19SimulatorConnection18connectToSimulatorEv
fun:_ZN18QtSimulatorPrivate19SimulatorConnection8instanceEv
fun:_ZN9QColormap10initializeEv
fun:_Z7qt_initP19QApplicationPrivatei
fun:_ZN19QApplicationPrivate9constructEv
fun:_ZN12QApplicationC1ERiPPci
fun:main
}@@#ifndef FINDDIALOG_H_
#define FINDDIALOG_H_#include <QDialog>
class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;class FindDialog : public QDialog
{
Q_OBJECT
public:
FindDialog( QWidget parent = 0 );
~FindDialog( );
signals:
void findNext( const QString &str, Qt::CaseSensitivity cs );
void findPrevious( const QString &str, Qt::CaseSensitivity cs );
private slots:
void findClicked( );
void enableFindButton( const QString &text );
private:
QLabel label;
QLineEdit *lineEdit;
QCheckBox *caseCheckBox;
QCheckBox *backwardCheckBox;
QPushButton *findButton;
QPushButton *closeButton;
};#endif/FINDDIALOG_H_/@
@#include <QtGui>
#include "finddialog.h"
FindDialog::FindDialog( QWidget *parent )
: QDialog( parent )
{
label = new QLabel( tr( "Find &what:" ) );
lineEdit = new QLineEdit;
label->setBuddy( lineEdit );
caseCheckBox = new QCheckBox( tr( "Match &case" ) );
backwardCheckBox = new QCheckBox( tr( "Search &backward" ) );
findButton = new QPushButton( tr( "&Find" ) );
findButton->setDefault( true );
findButton->setEnabled( false );
closeButton = new QPushButton( tr( "Close" ) );
connect( lineEdit, SIGNAL(textChanged( const QString & ) ),
this, SLOT( enableFindButton( const QString & ) ) );
connect( findButton, SIGNAL( clicked( ) ),
this, SLOT( findClicked( ) ) );
connect( closeButton, SIGNAL( clicked( ) ),
this, SLOT( close( ) ) );
QHBoxLayout *topLeftLayout = new QHBoxLayout;
topLeftLayout->addWidget( label );
topLeftLayout->addWidget( lineEdit );
QVBoxLayout *leftLayout = new QVBoxLayout;
leftLayout->addLayout( topLeftLayout);
leftLayout->addWidget( caseCheckBox );
leftLayout->addWidget( backwardCheckBox );
QVBoxLayout *rightLayout = new QVBoxLayout;
rightLayout->addWidget( findButton );
rightLayout->addWidget( closeButton );
rightLayout->addStretch( );
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout( leftLayout );
mainLayout->addLayout( rightLayout );
setLayout( mainLayout );
setWindowTitle( tr( "Find" ) );
setFixedHeight( sizeHint( ).height( ) );
}FindDialog::~FindDialog( )
{
/*
* Not needed to delete meber pointers
* pg. 18 states. "Qt automatically deletes
* child objects when the parent is destroyed,
* and the child widgets and layouts are all...
*/
delete label;
delete lineEdit;
delete caseCheckBox;
delete backwardCheckBox;
delete findButton;
delete closeButton;
}void FindDialog::findClicked( )
{
QString text = lineEdit->text( );
Qt::CaseSensitivity cs = caseCheckBox->isChecked( ) ? Qt::CaseSensitive
: Qt::CaseInsensitive;
if( backwardCheckBox->isChecked( ) )
{
emit findPrevious( text, cs );
}
else
{
emit findNext( text, cs );
}
}void FindDialog::enableFindButton( const QString &text )
{
findButton->setEnabled( !text.isEmpty( ) );
}@@#include <QApplication>
#include "finddialog.h")
{
QApplication app( argc, argv );
FindDialog *dialog = new FindDialog;
dialog->show( );
app.exec( );
delete dialog;
}@