Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
4.4.3
-
None
Description
QFontCache::~QFontCache (qfont.cpp) enters the "QFontCache::~QFontCache: engine = %p still has refcount %d" path. I don't know why the font engine still has a refcount at this point.
This example reproduces the leak:
#include <QtGui>
#include <QtDebug>
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget();
private slots:
void slotprint();
private:
QLineEdit *m_edit;
QPushButton *m_print;
};
MyWidget::MyWidget()
{
QVBoxLayout* mainLayout = new QVBoxLayout(this);
m_print = new QPushButton("print");
connect(m_print, SIGNAL(clicked()), this, SLOT(slotprint()));
m_edit = new QLineEdit;
mainLayout->addWidget(m_print);
mainLayout->addWidget(m_edit);
}
class PrintThread : public QThread
{
public:
PrintThread(QObject* parent)
: QThread(parent)
{
}
void run()
{ QImage image(128, 128, QImage::Format_ARGB32_Premultiplied); image.fill(0x0); QPainter p(&image); QTextDocument document; document.setPlainText(QLatin1String("render this string")); document.drawContents(&p); }};
void MyWidget::slotprint()
{
PrintThread* thread = new PrintThread(this);
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), this, SLOT(slotprint()));
m_edit->setText("foo");
m_print->setEnabled(false);
thread->start();
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyWidget* widget = new MyWidget();
widget->show();
return app.exec();
}
#include "main.moc"
Attachments
Issue Links
- is replaced by
-
QTBUG-3976 Memory leak in QFontCache
-
- Closed
-