Commit 47fd30b9 authored by Thomas Zander's avatar Thomas Zander

Add a KoShape::deleteLater() method which deletes the shape in a thread-safe manner (later on ;)

svn path=/trunk/koffice/; revision=689936
parent c0a087a8
......@@ -69,6 +69,7 @@ set(flake_SRCS
KoZoomStrategy.cpp
KoSvgPathParser.cpp
KoPathShapeLoader.cpp
ShapeDeleter_p.cpp
commands/KoShapeGroupCommand.cpp
commands/KoShapeAlignCommand.cpp
commands/KoShapeBackgroundCommand.cpp
......
......@@ -35,6 +35,7 @@
#include "KoShapeLoadingContext.h"
#include "KoViewConverter.h"
#include "KoLineBorder.h"
#include "ShapeDeleter_p.h"
#include <KoXmlReader.h>
#include <KoXmlWriter.h>
......@@ -593,6 +594,14 @@ void KoShape::setName( const QString & name ) {
d->name = name;
}
void KoShape::deleteLater() {
foreach(KoShapeManager *manager, d->shapeManagers)
manager->remove(this);
d->shapeManagers.clear();
new ShapeDeleter(this);
}
// loading & saving methods
void KoShape::saveOdfConnections(KoShapeSavingContext &context) const {
// TODO save "draw-glue-point" elements (9.2.19)
......
......@@ -597,6 +597,8 @@ public:
*/
virtual void waitUntilReady() const {}
void deleteLater();
protected:
/* ** loading saving helper methods */
......
/* This file is part of the KDE project
* Copyright (C) 2007 Thomas Zander <zander@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "ShapeDeleter_p.h"
#include "KoShape.h"
#include <QCoreApplication>
#include <QThread>
ShapeDeleter::ShapeDeleter(KoShape *shape)
: m_shape(shape)
{
moveToThread(QCoreApplication::instance()->thread());
deleteLater();
}
ShapeDeleter::~ShapeDeleter() {
Q_ASSERT(QThread::currentThread() == QCoreApplication::instance()->thread());
delete m_shape;
}
#include <ShapeDeleter_p.moc>
/* This file is part of the KDE project
* Copyright (C) 2007 Thomas Zander <zander@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef SHAPEDELETER_H
#define SHAPEDELETER_H
#include <QObject>
class KoShape;
class ShapeDeleter : public QObject {
Q_OBJECT
public:
ShapeDeleter(KoShape *shape);
~ShapeDeleter();
private:
KoShape *m_shape;
};
#endif
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