From 869164ca28e7c4a09ea1e0ab2fb9b72b2e838d20 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Wed, 12 Sep 2012 19:20:44 +0300 Subject: [PATCH] SANKORE-1069 Show Desktop: "Erase all" button isn't work --- src/adaptors/UBCFFSubsetAdaptor.cpp | 3 +- src/adaptors/UBSvgSubsetAdaptor.cpp | 33 ++++++---------- src/board/UBDrawingController.cpp | 18 +-------- src/board/UBDrawingController.h | 10 ----- src/core/UBApplicationController.cpp | 7 ---- src/core/UBPersistenceManager.cpp | 4 +- src/core/UBPersistenceManager.h | 2 +- src/core/UBSceneCache.cpp | 4 +- src/core/UBSceneCache.h | 2 +- src/desktop/UBDesktopAnnotationController.cpp | 6 +-- src/domain/UBGraphicsScene.cpp | 39 ++++++++----------- src/domain/UBGraphicsScene.h | 8 ++-- src/frameworks/UBCoreGraphicsScene.cpp | 19 +++------ 13 files changed, 48 insertions(+), 107 deletions(-) diff --git a/src/adaptors/UBCFFSubsetAdaptor.cpp b/src/adaptors/UBCFFSubsetAdaptor.cpp index 87c83cc4..ce733e3a 100644 --- a/src/adaptors/UBCFFSubsetAdaptor.cpp +++ b/src/adaptors/UBCFFSubsetAdaptor.cpp @@ -1146,8 +1146,7 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::repositionSvgItem(QGraphicsItem *ite bool UBCFFSubsetAdaptor::UBCFFSubsetReader::createNewScene() { - mCurrentScene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(mProxy, mProxy->pageCount()); - mCurrentScene->setURStackEnable(false); + mCurrentScene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(mProxy, mProxy->pageCount(), false); mCurrentScene->setSceneRect(mViewBox); if ((mCurrentScene->sceneRect().topLeft().x() >= 0) || (mCurrentScene->sceneRect().topLeft().y() >= 0)) { mShiftVector = -mViewBox.center(); diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index eee71e36..bcfa5199 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -380,7 +380,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() UBGraphicsStroke* annotationGroup = 0; UBGraphicsStrokesGroup* strokesGroup = 0; - UBDrawingController* dc = UBDrawingController::drawingController(); while (!mXmlReader.atEnd()) { @@ -395,8 +394,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() { if (!mScene) { - mScene = new UBGraphicsScene(mProxy); - mScene->setURStackEnable(false); + mScene = new UBGraphicsScene(mProxy, false); } // introduced in UB 4.2 @@ -514,10 +512,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() else annotationGroup = new UBGraphicsStroke(); - if(eDrawingMode_Vector == dc->drawingMode()){ - strokesGroup = new UBGraphicsStrokesGroup(); - graphicsItemFromSvg(strokesGroup); - } + + strokesGroup = new UBGraphicsStrokesGroup(); + graphicsItemFromSvg(strokesGroup); QStringRef ubZValue = mXmlReader.attributes().value(mNamespaceUri, "z-value"); @@ -561,14 +558,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() polygonItem->setStroke(annotationGroup); } - if(eDrawingMode_Vector == dc->drawingMode()){ - if(strokesGroup){ + + if(strokesGroup){ polygonItem->setTransform(strokesGroup->transform()); strokesGroup->addToGroup(polygonItem); polygonItem->setStrokesGroup(strokesGroup); - } - }else{ - mScene->addItem(polygonItem); } polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); @@ -588,14 +582,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() polygonItem->setStroke(annotationGroup); } - if(eDrawingMode_Vector == dc->drawingMode()){ - if(strokesGroup){ - polygonItem->setTransform(strokesGroup->transform()); - strokesGroup->addToGroup(polygonItem); - polygonItem->setStrokesGroup(strokesGroup); - } - }else{ - mScene->addItem(polygonItem); + + if(strokesGroup){ + polygonItem->setTransform(strokesGroup->transform()); + strokesGroup->addToGroup(polygonItem); + polygonItem->setStrokesGroup(strokesGroup); } polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); @@ -1014,7 +1005,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() delete annotationGroup; } - mScene->setURStackEnable(true); + mScene->enableUndoRedoStack(); return mScene; } diff --git a/src/board/UBDrawingController.cpp b/src/board/UBDrawingController.cpp index a539bc19..c70f85c1 100644 --- a/src/board/UBDrawingController.cpp +++ b/src/board/UBDrawingController.cpp @@ -47,7 +47,6 @@ UBDrawingController::UBDrawingController(QObject * parent) , mActiveRuler(NULL) , mStylusTool((UBStylusTool::Enum)-1) , mLatestDrawingTool((UBStylusTool::Enum)-1) - , mDrawingMode(DRAWING_MODE) , mIsDesktopMode(false) { connect(UBSettings::settings(), SIGNAL(colorContextChanged()), this, SIGNAL(colorPaletteChanged())); @@ -110,16 +109,10 @@ void UBDrawingController::setStylusTool(int tool) mStylusTool = (UBStylusTool::Enum)tool; - if(eDrawingMode_Vector == DRAWING_MODE && !mIsDesktopMode){ - mDrawingMode = eDrawingMode_Vector; - } - if (mStylusTool == UBStylusTool::Pen) UBApplication::mainWindow->actionPen->setChecked(true); - else if (mStylusTool == UBStylusTool::Eraser){ + else if (mStylusTool == UBStylusTool::Eraser) UBApplication::mainWindow->actionEraser->setChecked(true); - mDrawingMode = eDrawingMode_Artistic; - } else if (mStylusTool == UBStylusTool::Marker) UBApplication::mainWindow->actionMarker->setChecked(true); else if (mStylusTool == UBStylusTool::Selector) @@ -407,12 +400,3 @@ void UBDrawingController::captureToolSelected(bool checked) setStylusTool(UBStylusTool::Capture); } -void UBDrawingController::setDrawingMode(eDrawingMode mode) -{ - mDrawingMode = mode; -} - -eDrawingMode UBDrawingController::drawingMode() -{ - return mDrawingMode; -} diff --git a/src/board/UBDrawingController.h b/src/board/UBDrawingController.h index e2f822cf..eb762d1f 100644 --- a/src/board/UBDrawingController.h +++ b/src/board/UBDrawingController.h @@ -22,13 +22,6 @@ class UBAbstractDrawRuler; -typedef enum{ - eDrawingMode_Artistic, - eDrawingMode_Vector -}eDrawingMode; - -#define DRAWING_MODE eDrawingMode_Vector - class UBDrawingController : public QObject { Q_OBJECT; @@ -56,8 +49,6 @@ class UBDrawingController : public QObject void setPenColor(bool onDarkBackground, const QColor& color, int pIndex); void setMarkerColor(bool onDarkBackground, const QColor& color, int pIndex); void setMarkerAlpha(qreal alpha); - void setDrawingMode(eDrawingMode mode); - eDrawingMode drawingMode(); UBAbstractDrawRuler* mActiveRuler; @@ -86,7 +77,6 @@ class UBDrawingController : public QObject private: UBStylusTool::Enum mStylusTool; UBStylusTool::Enum mLatestDrawingTool; - eDrawingMode mDrawingMode; bool mIsDesktopMode; static UBDrawingController* sDrawingController; diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 867e2b8c..3cf420af 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -464,7 +464,6 @@ void UBApplicationController::showDesktop(bool dontSwitchFrontProcess) } UBDrawingController::drawingController()->setInDestopMode(true); - UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Artistic); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); } @@ -598,12 +597,6 @@ void UBApplicationController::checkUpdateRequest() void UBApplicationController::hideDesktop() { - - - if(UBStylusTool::Eraser != UBDrawingController::drawingController()->stylusTool()){ - UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector); - } - if (mMainMode == Board) { showBoard(); diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 6250ff32..e7a609d8 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -493,7 +493,7 @@ void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int in } -UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* proxy, int index) +UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* proxy, int index, bool useUndoRedoStack) { int count = sceneCount(proxy); @@ -502,7 +502,7 @@ UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* pr mSceneCache.shiftUpScenes(proxy, index, count -1); - UBGraphicsScene *newScene = mSceneCache.createScene(proxy, index); + UBGraphicsScene *newScene = mSceneCache.createScene(proxy, index, useUndoRedoStack); newScene->setBackground(UBSettings::settings()->isDarkBackground(), UBSettings::settings()->UBSettings::isCrossedBackground()); diff --git a/src/core/UBPersistenceManager.h b/src/core/UBPersistenceManager.h index 79624b18..ddd0c5db 100644 --- a/src/core/UBPersistenceManager.h +++ b/src/core/UBPersistenceManager.h @@ -62,7 +62,7 @@ class UBPersistenceManager : public QObject virtual void persistDocumentScene(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* pScene, const int pSceneIndex); - virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index); + virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index, bool useUndoRedoStack = true); virtual void insertDocumentSceneAt(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* scene, int index); diff --git a/src/core/UBSceneCache.cpp b/src/core/UBSceneCache.cpp index 6b16f87a..41063433 100644 --- a/src/core/UBSceneCache.cpp +++ b/src/core/UBSceneCache.cpp @@ -38,9 +38,9 @@ UBSceneCache::~UBSceneCache() } -UBGraphicsScene* UBSceneCache::createScene(UBDocumentProxy* proxy, int pageIndex) +UBGraphicsScene* UBSceneCache::createScene(UBDocumentProxy* proxy, int pageIndex, bool useUndoRedoStack) { - UBGraphicsScene* newScene = new UBGraphicsScene(proxy); + UBGraphicsScene* newScene = new UBGraphicsScene(proxy, useUndoRedoStack); insert(proxy, pageIndex, newScene); return newScene; diff --git a/src/core/UBSceneCache.h b/src/core/UBSceneCache.h index 9c938299..44aa9ab5 100644 --- a/src/core/UBSceneCache.h +++ b/src/core/UBSceneCache.h @@ -64,7 +64,7 @@ class UBSceneCache : public QHash UBSceneCache(); virtual ~UBSceneCache(); - UBGraphicsScene* createScene(UBDocumentProxy* proxy, int pageIndex); + UBGraphicsScene* createScene(UBDocumentProxy* proxy, int pageIndex, bool useUndoRedoStack); void insert (UBDocumentProxy* proxy, int pageIndex, UBGraphicsScene* scene ); diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 547be184..bb3fdbe1 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -81,7 +81,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent, UB QString backgroundStyle = "QWidget {background-color: rgba(127, 127, 127, 0)}"; mTransparentDrawingView->setStyleSheet(backgroundStyle); - mTransparentDrawingScene = new UBGraphicsScene(0); + mTransparentDrawingScene = new UBGraphicsScene(0, false); mTransparentDrawingView->setScene(mTransparentDrawingScene); mTransparentDrawingScene->setDrawingMode(true); @@ -372,10 +372,6 @@ void UBDesktopAnnotationController::goToUniboard() UBPlatformUtils::setDesktopMode(false); UBDrawingController::drawingController()->setInDestopMode(false); - if(UBStylusTool::Eraser != UBDrawingController::drawingController()->stylusTool()){ - UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector); - } - emit restoreUniboard(); } diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index fd3bb6da..1b1afe81 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -254,7 +254,7 @@ void UBZLayerController::setLayerType(QGraphicsItem *pItem, itemLayerType::Enum pItem->setData(UBGraphicsItemData::itemLayerType, QVariant(pNewType)); } -UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) +UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoStack) : UBCoreGraphicsScene(parent) , mEraser(0) , mPointer(0) @@ -271,7 +271,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) , mCurrentStroke(0) , mShouldUseOMP(true) , mItemCount(0) - , enableUndoRedoStack(true) + , mUndoRedoStackEnabled(enableUndoRedoStack) , magniferControlViewWidget(0) , magniferDisplayViewWidget(0) , mZLayerController(new UBZLayerController(this)) @@ -558,7 +558,7 @@ bool UBGraphicsScene::inputDeviceRelease() if (dc->isDrawingTool() || mDrawWithCompass) { if(mArcPolygonItem){ - if(eDrawingMode_Vector == dc->drawingMode()){ + UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup(); // Add the arc @@ -580,10 +580,9 @@ bool UBGraphicsScene::inputDeviceRelease() mAddedItems << pStrokes; addItem(pStrokes); mDrawWithCompass = false; - } + }else if (mCurrentStroke) { - if(eDrawingMode_Vector == UBDrawingController::drawingController()->drawingMode()){ UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup(); // Remove the strokes that were just drawn here and replace them by a stroke item @@ -600,7 +599,6 @@ bool UBGraphicsScene::inputDeviceRelease() mAddedItems.clear(); mAddedItems << pStrokes; addItem(pStrokes); - } if (mCurrentStroke->polygons().empty()){ delete mCurrentStroke; @@ -612,7 +610,7 @@ bool UBGraphicsScene::inputDeviceRelease() if (mRemovedItems.size() > 0 || mAddedItems.size() > 0) { - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack if(UBApplication::undoStack) @@ -751,10 +749,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, if (!mCurrentStroke) mCurrentStroke = new UBGraphicsStroke(); - if (mCurrentStroke) - { - polygonItem->setStroke(mCurrentStroke); - } + polygonItem->setStroke(mCurrentStroke); mPreviousPolygonItems.append(polygonItem); @@ -1002,7 +997,7 @@ void UBGraphicsScene::leaveEvent(QEvent * event) UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const { - UBGraphicsScene* copy = new UBGraphicsScene(this->document()); + UBGraphicsScene* copy = new UBGraphicsScene(this->document(), this->mUndoRedoStackEnabled); copy->setBackground(this->isDarkBackground(), this->isCrossedBackground()); copy->setSceneRect(this->sceneRect()); @@ -1138,7 +1133,7 @@ void UBGraphicsScene::clearContent(clearCase pCase) // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint update(sceneRect()); - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet(), groupsMap); UBApplication::undoStack->push(uc); @@ -1165,7 +1160,7 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi addItem(pixmapItem); - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, replaceFor, pixmapItem); UBApplication::undoStack->push(uc); } @@ -1192,7 +1187,7 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem) { - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsTextItemUndoCommand* uc = new UBGraphicsTextItemUndoCommand(textItem); UBApplication::undoStack->push(uc); } @@ -1213,7 +1208,7 @@ UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool s mediaItem->show(); - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, mediaItem); UBApplication::undoStack->push(uc); } @@ -1296,7 +1291,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co // graphicsWidget->widgetWebView()->loadMainHtml(); graphicsWidget->setSelected(true); - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget); UBApplication::undoStack->push(uc); } @@ -1362,7 +1357,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QListsetVisible(true); groupItem->setFocus(); - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsItemGroupUndoCommand* uc = new UBGraphicsItemGroupUndoCommand(this, groupItem); UBApplication::undoStack->push(uc); } @@ -1391,7 +1386,7 @@ void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem) groupItem->setUuid(QUuid::createUuid()); } - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, groupItem); UBApplication::undoStack->push(uc); } @@ -1421,7 +1416,7 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint addItem(svgItem); - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, svgItem); UBApplication::undoStack->push(uc); } @@ -1511,7 +1506,7 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con textItem->show(); - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem); UBApplication::undoStack->push(uc); } @@ -1535,7 +1530,7 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q addItem(textItem); textItem->show(); - if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented + if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem); UBApplication::undoStack->push(uc); } diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h index 3722d8be..5f406d10 100644 --- a/src/domain/UBGraphicsScene.h +++ b/src/domain/UBGraphicsScene.h @@ -109,10 +109,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem }; // tmp stub for divide addings scene objects from undo mechanism implementation - void setURStackEnable(bool set = true) {enableUndoRedoStack = set;} - bool isURStackIsEnabled(){ return enableUndoRedoStack;} + bool isURStackIsEnabled(){ return mUndoRedoStackEnabled;} + void enableUndoRedoStack(){mUndoRedoStackEnabled = true;} - UBGraphicsScene(UBDocumentProxy *parent); + UBGraphicsScene(UBDocumentProxy *parent, bool enableUndoRedoStack = true); virtual ~UBGraphicsScene(); virtual UBItem* deepCopy() const; @@ -405,7 +405,7 @@ public slots: bool mHasCache; // tmp stub for divide addings scene objects from undo mechanism implementation - bool enableUndoRedoStack; + bool mUndoRedoStackEnabled; UBMagnifier *magniferControlViewWidget; UBMagnifier *magniferDisplayViewWidget; diff --git a/src/frameworks/UBCoreGraphicsScene.cpp b/src/frameworks/UBCoreGraphicsScene.cpp index 28dd6a9f..69f05dea 100644 --- a/src/frameworks/UBCoreGraphicsScene.cpp +++ b/src/frameworks/UBCoreGraphicsScene.cpp @@ -32,23 +32,17 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene() { //we must delete removed items that are no more in any scene //at groups deleting some items can be added to mItemsToDelete, so we need to use iterators. - if (mItemsToDelete.count()) + foreach(QGraphicsItem* item, mItemsToDelete) { - QSet::iterator it = mItemsToDelete.begin(); - QGraphicsItem* item = *it; - do + if (item) { - item = *it; - if (item && (item->scene() == NULL || item->scene() == this)) + if (item->scene() == NULL || item->scene() == this) { - mItemsToDelete.remove(*it); delete item; } - - it = mItemsToDelete.begin(); - - }while(mItemsToDelete.count()); + } } + mItemsToDelete.clear(); } void UBCoreGraphicsScene::addItem(QGraphicsItem* item) @@ -84,12 +78,11 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item) if(mItemsToDelete.contains(item)) { UBGraphicsItem *item_casted = dynamic_cast(item); - if (0 != item_casted) + if (item_casted != NULL) item_casted->clearSource(); mItemsToDelete.remove(item); delete item; - item = 0; return true; } else