Commit 218cc824 authored by Jan Möbius's avatar Jan Möbius
Browse files

Revert last change, as it caused crashes



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15196 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 1c977621
......@@ -60,9 +60,6 @@
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <QFileInfo>
#ifdef USE_OPENMP
#include <omp.h>
#endif
//== TYPEDEFS =================================================================
......@@ -85,11 +82,9 @@ BaseObject::BaseObject(const BaseObject& _object) :
flags_(_object.flags_),
visible_(_object.visible_),
parentItem_(0),
row_(0),
path_("."),
filename_("")
{
// Increase id generator as we created a new object
++idGenerator;
......@@ -145,7 +140,6 @@ BaseObject::BaseObject(BaseObject* _parent) :
flags_(),
visible_(true),
parentItem_(_parent),
row_(0),
name_("NONAME")
{
id_ = idGenerator;
......@@ -464,7 +458,10 @@ int BaseObject::level() {
int BaseObject::row() const
{
return row_;
if (parentItem_)
return parentItem_->childItems_.indexOf(const_cast<BaseObject*>(this));
return 0;
}
BaseObject* BaseObject::parent()
......@@ -496,10 +493,9 @@ void BaseObject::setParent(BaseObject* _parent) {
void BaseObject::appendChild(BaseObject *item)
{
if ( !childItems_.contains(item) ) {
if ( !childItems_.contains(item) )
childItems_.append(item);
item->row_ = childItems_.size() - 1;
} else
else
std::cerr << "Warning! Trying to append a child twice! Remove the append calls from your File plugin!" << std::endl;
}
......@@ -547,22 +543,21 @@ BaseObject* BaseObject::childExists(QString _name) {
void BaseObject::removeChild( BaseObject* _item ) {
int idx = (_item != 0) ? _item->row_ : -1;
if ( (idx < 0) || (idx >= childItems_.size()) || (childItems_[idx] != _item) ) {
std::cerr << "BaseObject: Illegal removeChild request" << std::endl;
return;
bool found = false;
QList<BaseObject*>::iterator i;
for (i = childItems_.begin(); i != childItems_.end(); ++i) {
if ( *i == _item ) {
found = true;
break;
}
}
childItems_.removeAt(idx);
#ifdef USE_OPENMP
#pragma omp parallel for
#endif
for ( int i = idx ; i < childItems_.size(); ++i ) {
--(childItems_[idx]->row_);
if ( !found ) {
std::cerr << "Illegal remove request" << std::endl;
return;
}
childItems_.erase(i);
}
QList< BaseObject* > BaseObject::getLeafs() {
......@@ -596,7 +591,6 @@ void BaseObject::deleteSubtree() {
childItems_.clear();
}
// ===============================================================================
// Grouping
// ===============================================================================
......
......@@ -339,11 +339,6 @@ class DLLEXPORTONLY BaseObject : public QObject {
/// Set the parent pointer
void setParent(BaseObject* _parent);
private:
// Cache the row in the parents array for speed efficiency
int row_;
/** @} */
//===========================================================================
......
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