Commit 235bcd1d authored by Boudewijn Rempt's avatar Boudewijn Rempt

Remove workaround for bugs in Qt3's QValueVector

parent ecf3a3c8
......@@ -4,7 +4,7 @@ add_subdirectory( tests )
add_definitions(${KDE4_ENABLE_EXCEPTIONS})
# Chose a tiles backend
# Chose a tiles backend
# 1 - image/tiles
# 3 - image/tiles3
......@@ -298,12 +298,12 @@ install( FILES
metadata/schemas/xmp.schema
metadata/schemas/xmpmm.schema
metadata/schemas/xmprights.schema
DESTINATION ${DATA_INSTALL_DIR}/krita/metadata/schemas)
########### install files ###############
install( FILES
install( FILES
kis_base_node.h
kis_base_processor.h
kis_config_widget.h
......@@ -334,7 +334,6 @@ install( FILES
kis_selection.h
kis_shared.h
kis_shared_ptr.h
kis_shared_ptr_vector.h
kis_transaction.h
kis_types.h
krita_export.h
......
......@@ -29,7 +29,6 @@
#define _KIS_ANNOTATION_H_
#include <kis_shared.h>
#include "kis_shared_ptr_vector.h"
#include <QByteArray>
#include <QString>
......
/*
* Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_SHARED_PTR_VECTOR_H
#define KIS_SHARED_PTR_VECTOR_H
#include <QVector>
#include <kis_shared_ptr.h>
/**
* QValueVector does not always destroy an element when it is erased.
* If the items it is holding are KisSharedPtr, this can result in hidden
* references to objects that cannot be accounted for. This class
* sets the KisSharedPtr to 0 on erase, which dereferences the object as
* expected.
*/
template <class T>
class KisSharedPtrVector : public QVector< KisSharedPtr<T> >
{
typedef QVector< KisSharedPtr<T> > SharedPtrVector;
public:
KisSharedPtrVector() {}
void pop_back() {
if (!SharedPtrVector::empty()) {
SharedPtrVector::back() = 0;
SharedPtrVector::pop_back();
}
}
typename SharedPtrVector::iterator erase(typename SharedPtrVector::iterator it) {
*it = 0;
return SharedPtrVector::erase(it);
}
typename SharedPtrVector::iterator erase(typename SharedPtrVector::iterator first, typename SharedPtrVector::iterator last) {
qFill(first, last, 0);
return SharedPtrVector::erase(first, last);
}
bool contains(KisSharedPtr<T> ptr) const {
for (int i = 0, n = SharedPtrVector::count(); i < n; ++i)
if (SharedPtrVector::at(i) == ptr)
return true;
return false;
}
};
#endif // KIS_SHARED_PTR_VECTOR_H
......@@ -37,8 +37,6 @@ uint qHash(KisWeakSharedPtr<T> ptr) {
return qHash(ptr.data());
}
#include "kis_shared_ptr_vector.h"
/**
* Define lots of shared pointer versions of Krita classes.
* Shared pointer classes have the advantage of near automatic
......@@ -53,9 +51,8 @@ typedef KisWeakSharedPtr<KisImage> KisImageWSP;
class KisPaintDevice;
typedef KisSharedPtr<KisPaintDevice> KisPaintDeviceSP;
typedef KisWeakSharedPtr<KisPaintDevice> KisPaintDeviceWSP;
typedef KisSharedPtrVector<KisPaintDevice> vKisPaintDeviceSP;
typedef QVector<KisPaintDeviceSP> vKisPaintDeviceSP;
typedef vKisPaintDeviceSP::iterator vKisPaintDeviceSP_it;
typedef vKisPaintDeviceSP::const_iterator vKisPaintDeviceSP_cit;
class KisFixedPaintDevice;
typedef KisSharedPtr<KisFixedPaintDevice> KisFixedPaintDeviceSP;
......@@ -67,7 +64,7 @@ typedef KisWeakSharedPtr<KisMask> KisMaskWSP;
class KisNode;
typedef KisSharedPtr<KisNode> KisNodeSP;
typedef KisWeakSharedPtr<KisNode> KisNodeWSP;
typedef KisSharedPtrVector<KisNode> vKisNodeSP;
typedef QVector<KisNodeSP> vKisNodeSP;
typedef vKisNodeSP::iterator vKisNodeSP_it;
typedef vKisNodeSP::const_iterator vKisNodeSP_cit;
......@@ -143,7 +140,7 @@ typedef KisSharedPtr<KisConvolutionKernel> KisConvolutionKernelSP;
class KisAnnotation;
typedef KisSharedPtr<KisAnnotation> KisAnnotationSP;
typedef KisSharedPtrVector<KisAnnotation> vKisAnnotationSP;
typedef QVector<KisAnnotationSP> vKisAnnotationSP;
typedef vKisAnnotationSP::iterator vKisAnnotationSP_it;
typedef vKisAnnotationSP::const_iterator vKisAnnotationSP_cit;
......
......@@ -451,12 +451,6 @@ target_link_libraries(KisSharedPtrTest ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTES
########### next target ###############
set(kis_shared_ptr_vector_test_SRCS kis_shared_ptr_vector_test.cpp )
kde4_add_unit_test(KisSharedPtrVectorTest TESTNAME krita-image-KisSharedPtrVectorTest ${kis_shared_ptr_vector_test_SRCS})
target_link_libraries(KisSharedPtrVectorTest ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
########### next target ###############
set(kis_transform_worker_test_SRCS kis_transform_worker_test.cpp )
kde4_add_unit_test(KisTransformWorkerTest TESTNAME krita-image-KisTransformWorkerTest ${kis_transform_worker_test_SRCS})
target_link_libraries(KisTransformWorkerTest ${KDE4_KDEUI_LIBS} kritaimage ${QT_QTTEST_LIBRARY})
......
......@@ -21,7 +21,6 @@
#include "kis_shared_ptr.h"
#include "kis_shared_ptr_vector.h"
#include "kis_shared.h"
class TestClassWatcher
......@@ -53,7 +52,7 @@ public:
typedef KisSharedPtr<TestClass> TestClassSP;
typedef KisWeakSharedPtr<TestClass> TestClassWSP;
typedef KisSharedPtrVector<TestClass> vTestClassSP;
typedef QVector<TestClass> vTestClassSP;
typedef vTestClassSP::iterator vTestClassSP_it;
typedef vTestClassSP::const_iterator vTestClassSP_cit;
......
/*
* Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_shared_ptr_vector_test.h"
#include <qtest_kde.h>
#include "kis_shared_ptr_vector.h"
#include "kis_shared.h"
class Test : public KisShared
{
};
void KisSharedPtrVectorTest::testCreation()
{
KisSharedPtrVector<Test> test;
}
QTEST_KDEMAIN(KisSharedPtrVectorTest, GUI)
#include "kis_shared_ptr_vector_test.moc"
/*
* Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_SHARED_PTR_VECTOR_TEST_H
#define KIS_SHARED_PTR_VECTOR_TEST_H
#include <QtTest>
class KisSharedPtrVectorTest : public QObject
{
Q_OBJECT
private slots:
void testCreation();
};
#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