summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-04 22:21:44 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-04 22:21:44 (GMT)
commit95896d8864831c476de579bff47cc5646cf160f3 (patch)
treedd4e9a940d41619a00759197c8997d5b6bf18072
parent9f15f1590606805e28ecf9dffedb89c08f6916ae (diff)
Fix mem leak when we print (need new kmail too)
-rw-r--r--CMakeLists.txt2
-rw-r--r--messageviewer/src/viewer/viewer.cpp7
-rw-r--r--messageviewer/src/viewer/viewer.h5
-rw-r--r--messageviewer/src/viewer/viewer_p.cpp14
-rw-r--r--messageviewer/src/viewer/viewer_p.h4
5 files changed, 29 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0137c82..3c2a4d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
-set(PIM_VERSION "5.3.80")
+set(PIM_VERSION "5.3.81")
set(MESSAGELIB_LIB_VERSION ${PIM_VERSION})
set(AKONADIMIME_LIB_VERSION "5.3.40")
diff --git a/messageviewer/src/viewer/viewer.cpp b/messageviewer/src/viewer/viewer.cpp
index 547abb9..09133e1 100644
--- a/messageviewer/src/viewer/viewer.cpp
+++ b/messageviewer/src/viewer/viewer.cpp
@@ -85,6 +85,7 @@ void Viewer::initialize()
connect(d_ptr, &ViewerPrivate::moveMessageToTrash, this, &Viewer::moveMessageToTrash);
connect(d_ptr, &ViewerPrivate::executeMailAction, this, &Viewer::executeMailAction);
connect(d_ptr, &ViewerPrivate::pageIsScrolledToBottom, this, &Viewer::pageIsScrolledToBottom);
+ connect(d_ptr, &ViewerPrivate::printingFinished, this, &Viewer::printingFinished);
setMessage(KMime::Message::Ptr(), MimeTreeParser::Delayed);
}
@@ -436,6 +437,12 @@ QAction *Viewer::urlOpenAction() const
return d->mUrlOpenAction;
}
+bool Viewer::printingMode() const
+{
+ Q_D(const Viewer);
+ return d->printingMode();
+}
+
void Viewer::setPrinting(bool enable)
{
Q_D(Viewer);
diff --git a/messageviewer/src/viewer/viewer.h b/messageviewer/src/viewer/viewer.h
index 4e4b711..254b58a 100644
--- a/messageviewer/src/viewer/viewer.h
+++ b/messageviewer/src/viewer/viewer.h
@@ -326,6 +326,9 @@ public:
void runJavaScript(const QString &code);
void setPrintElementBackground(bool printElementBackground);
+
+ bool printingMode() const;
+
Q_SIGNALS:
void moveMessageToTrash();
void pageIsScrolledToBottom(bool);
@@ -369,6 +372,8 @@ Q_SIGNALS:
void makeResourceOnline(MessageViewer::Viewer::ResourceOnlineMode mode);
+ void printingFinished();
+
private:
void initialize();
diff --git a/messageviewer/src/viewer/viewer_p.cpp b/messageviewer/src/viewer/viewer_p.cpp
index 3fb2a0d..ba3000f 100644
--- a/messageviewer/src/viewer/viewer_p.cpp
+++ b/messageviewer/src/viewer/viewer_p.cpp
@@ -1266,11 +1266,18 @@ void ViewerPrivate::setOverrideEncoding(const QString &encoding)
update(MimeTreeParser::Force);
}
+
+
void ViewerPrivate::setPrinting(bool enable)
{
mPrinting = enable;
}
+bool ViewerPrivate::printingMode() const
+{
+ return mPrinting;
+}
+
void ViewerPrivate::printMessage(const Akonadi::Item &message)
{
disconnect(mPartHtmlWriter.data(), &WebEnginePartHtmlWriter::finished, this, &ViewerPrivate::slotPrintMessage);
@@ -2306,7 +2313,9 @@ void ViewerPrivate::slotPrintPreview()
}
QPointer<WebEngineViewer::WebEnginePrintMessageBox> dialog = new WebEngineViewer::WebEnginePrintMessageBox(q);
connect(dialog.data(), &WebEngineViewer::WebEnginePrintMessageBox::openInBrowser, this, &ViewerPrivate::slotOpenInBrowser);
- dialog->exec();
+ if (!dialog->exec()) {
+ Q_EMIT printingFinished();
+ }
delete dialog;
}
@@ -2323,11 +2332,13 @@ void ViewerPrivate::slotExportHtmlPageSuccess(const QString &filename)
{
const QUrl url(QUrl::fromLocalFile(filename));
KRun::runUrl(url, QStringLiteral("text/html"), q, true);
+ Q_EMIT printingFinished();
}
void ViewerPrivate::slotExportHtmlPageFailed()
{
qCDebug(MESSAGEVIEWER_LOG) << " Export HTML failed";
+ Q_EMIT printingFinished();
}
void ViewerPrivate::slotPrintMessage()
@@ -2361,6 +2372,7 @@ void ViewerPrivate::slotHandlePagePrinted(bool result)
Q_UNUSED(result);
delete mCurrentPrinter;
mCurrentPrinter = Q_NULLPTR;
+ Q_EMIT printingFinished();
}
void ViewerPrivate::slotSetEncoding()
diff --git a/messageviewer/src/viewer/viewer_p.h b/messageviewer/src/viewer/viewer_p.h
index 46790f9..21414e8 100644
--- a/messageviewer/src/viewer/viewer_p.h
+++ b/messageviewer/src/viewer/viewer_p.h
@@ -313,7 +313,8 @@ public:
void setOverrideEncoding(const QString &encoding);
/** Set printing mode */
- virtual void setPrinting(bool enable);
+ void setPrinting(bool enable);
+ bool printingMode() const;
/** Print message. */
void printMessage(const Akonadi::Item &msg);
@@ -584,6 +585,7 @@ Q_SIGNALS:
void moveMessageToTrash();
void executeMailAction(MessageViewer::Viewer::MailAction type);
void pageIsScrolledToBottom(bool);
+ void printingFinished();
private:
QString attachmentInjectionHtml();
QString recipientsQuickListLinkHtml(const QString &);