Printing: handle memory leak in printer class

Don't initialize new webview each time we print.
Delete the QWebView object in the destructor.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Gehad elrobey 2015-07-10 14:59:56 +02:00 committed by Lubomir I. Ivanov
parent 85bce0fa0d
commit 51e36fa158
2 changed files with 7 additions and 1 deletions

View file

@ -13,6 +13,12 @@ Printer::Printer(QPrinter *printer, print_options *printOptions, template_option
this->templateOptions = templateOptions;
dpi = 0;
done = 0;
webView = new QWebView();
}
Printer::~Printer()
{
delete webView;
}
void Printer::putProfileImage(QRect profilePlaceholder, QRect viewPort, QPainter *painter, struct dive *dive, QPointer<ProfileWidget2> profile)
@ -118,7 +124,6 @@ void Printer::templateProgessUpdated(int value)
void Printer::print()
{
TemplateLayout t(printOptions, templateOptions);
webView = new QWebView();
connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int)));
dpi = printer->resolution();

View file

@ -29,6 +29,7 @@ private slots:
public:
Printer(QPrinter *printer, print_options *printOptions, template_options *templateOptions);
~Printer();
void print();
signals: