Commit 1a6d1763 authored by Laurent Montel's avatar Laurent Montel 😁

Fix Bug 358116 - messageviewer leaks temporary files with mail parts in it

when we crash kmail too.
BUG: 358116
parent 5f2f2b8a
......@@ -1008,6 +1008,7 @@ static void kmCrashHandler(int sigId)
kmkernel->dumpDeadLetters();
fprintf(stderr, "*** Dead letters dumped.\n");
kmkernel->stopAgentInstance();
kmkernel->cleanupTemporaryFiles();
}
}
......@@ -1259,6 +1260,11 @@ bool KMKernel::haveSystemTrayApplet() const
return mSystemTray != nullptr;
}
QTextCodec *KMKernel::networkCodec() const
{
return mNetCodec;
}
void KMKernel::updateSystemTray()
{
if (mSystemTray && !the_shuttingDown) {
......@@ -1642,6 +1648,21 @@ void KMKernel::updatedTemplates()
Q_EMIT customTemplatesChanged();
}
void KMKernel::cleanupTemporaryFiles()
{
QDir dir(QDir::tempPath());
const QStringList lst = dir.entryList(QStringList{QStringLiteral("messageviewer_*")});
qDebug() << " list file to delete " << lst;
for (const QString &file : lst) {
QDir tempDir(QDir::tempPath() + QLatin1Char('/') + file);
if (!tempDir.removeRecursively()) {
fprintf(stderr, "%s was not removed .\n", qPrintable(tempDir.absolutePath()));
} else {
fprintf(stderr, "%s was removed .\n", qPrintable(tempDir.absolutePath()));
}
}
}
void KMKernel::stopAgentInstance()
{
const QString resourceGroupPattern(QStringLiteral("Resource %1"));
......
......@@ -366,10 +366,7 @@ public:
*/
bool haveSystemTrayApplet() const;
QTextCodec *networkCodec() const
{
return mNetCodec;
}
QTextCodec *networkCodec() const;
/** returns a reference to the first Mainwin or a temporary Mainwin */
KMainWindow *mainWin();
......@@ -424,6 +421,7 @@ public:
Akonadi::Search::PIM::IndexedItems *indexedItems() const;
void cleanupTemporaryFiles();
protected:
void agentInstanceBroken(const Akonadi::AgentInstance &instance);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment