Fixed a few memory leaks

This commit is contained in:
Olivier Teulière 2012-04-15 23:11:07 +02:00
parent 0a2727e767
commit f3f2d916bb
3 changed files with 18 additions and 3 deletions

View file

@ -54,6 +54,7 @@ string StackTrace::GetStack()
{
oss << " at " << Demangle(symbols[i]) << endl;
}
free (symbols);
return oss.str();
#else

View file

@ -118,13 +118,13 @@ MainWindow::MainWindow(QWidget *iParent)
// Status bar
statusBar()->addWidget(new QLabel, 1);
// First widget, not added yet
m_lettersLabel = new QLabel;
m_lettersLabel = new QLabel(statusBar());
m_lettersLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel);
// Second widget, not added yet
m_turnLabel = new QLabel;
m_turnLabel = new QLabel(statusBar());
m_turnLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel);
// Third widget
m_dicNameLabel = new QLabel;
m_dicNameLabel = new QLabel(this);
m_dicNameLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel);
statusBar()->addPermanentWidget(m_dicNameLabel);
QObject::connect(this, SIGNAL(dicChanged(const Dictionary*)),
@ -202,6 +202,10 @@ MainWindow::~MainWindow()
delete m_game;
delete m_dic;
delete m_timerModel;
// Destroy singletons
GameFactory::Destroy();
Settings::Destroy();
}

View file

@ -76,6 +76,15 @@ wchar_t *rl_gets()
delete[] wline_read;
}
static bool init = true;
if (init)
{
// Initialize readline() explicitly, to help filtering
// valgrind results
rl_initialize();
init = false;
}
// Get a line from the user
static char *line_read;
line_read = readline("commande> ");
@ -944,6 +953,7 @@ int main(int argc, char *argv[])
mainLoop(dic);
GameFactory::Destroy();
Settings::Destroy();
// Free the readline static variable
if (wline_read)