Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 518eea7a authored by Boudewijn Rempt's avatar Boudewijn Rempt

Delete documents created by libkis directly

Otherwise you will have to wait until the even loop kicks back
in before the images are really deleted, and that only happens
after the script is done running.

CCBUG:412740
(cherry picked from commit 543565e9cb5d1ddd8fd46bbd65e98e46d059a507)
parent 64e4e0fe
......@@ -92,6 +92,7 @@ Document::~Document()
{
if (d->ownsDocument && d->document) {
KisPart::instance()->removeDocument(d->document);
delete d->document;
}
delete d;
}
......@@ -451,6 +452,7 @@ QByteArray Document::pixelData(int x, int y, int w, int h) const
bool Document::close()
{
bool retval = d->document->closeUrl(false);
Q_FOREACH(KisView *view, KisPart::instance()->views()) {
if (view->document() == d->document) {
view->close();
......@@ -459,7 +461,11 @@ bool Document::close()
}
}
KisPart::instance()->removeDocument(d->document);
KisPart::instance()->removeDocument(d->document, !d->ownsDocument);
if (d->ownsDocument) {
delete d->document;
}
d->document = 0;
return retval;
}
......
......@@ -227,13 +227,15 @@ int KisPart::documentCount() const
return d->documents.size();
}
void KisPart::removeDocument(KisDocument *document)
void KisPart::removeDocument(KisDocument *document, bool deleteDocument)
{
if (document) {
d->documents.removeAll(document);
emit documentClosed('/' + objectName());
emit sigDocumentRemoved(document->url().toLocalFile());
document->deleteLater();
if (deleteDocument) {
document->deleteLater();
}
}
}
......
......@@ -109,7 +109,7 @@ public:
*/
int documentCount() const;
void removeDocument(KisDocument *document);
void removeDocument(KisDocument *document, bool deleteDocument = true);
// ----------------- MainWindow management -----------------
......
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