From 214e0711badf4b12f06163e34ea7f796fde4f5c2 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Thu, 3 May 2012 17:18:49 +0300 Subject: [PATCH] Some memory-leaks problems detected and fixed --- src/adaptors/UBExportCFF.cpp | 1 + src/board/UBBoardPaletteManager.cpp | 23 +++++--- src/board/UBBoardPaletteManager.h | 8 +++ src/board/UBFeaturesController.cpp | 53 +++++++++---------- src/board/UBFeaturesController.h | 7 +-- src/customWidgets/UBActionableWidget.cpp | 2 + src/customWidgets/UBMediaWidget.cpp | 2 + src/domain/UBAbstractUndoCommand.cpp | 2 + src/domain/UBAngleWidget.cpp | 2 + src/domain/UBGraphicsItemUndoCommand.cpp | 4 +- src/domain/UBGraphicsMediaItem.cpp | 4 +- src/domain/UBGraphicsStrokesGroup.cpp | 2 + src/domain/UBGraphicsTextItemDelegate.cpp | 3 +- src/domain/ubgraphicsgroupcontaineritem.cpp | 2 + .../ubgraphicsgroupcontaineritemdelegate.cpp | 3 +- src/frameworks/UBCoreGraphicsScene.cpp | 3 +- src/gui/UBDockDownloadWidget.cpp | 2 + src/gui/UBDockTeacherGuideWidget.cpp | 2 + src/gui/UBFeaturesActionBar.cpp | 1 + src/gui/UBFeaturesWidget.cpp | 39 +++++++++----- src/gui/UBFeaturesWidget.h | 4 +- src/gui/UBLibItemProperties.cpp | 3 +- src/gui/UBLibNavigatorWidget.cpp | 3 +- src/gui/UBLibPathViewer.cpp | 3 +- src/gui/UBLibWebView.cpp | 3 +- src/gui/UBLibWidget.cpp | 3 +- src/gui/UBPageNavigationWidget.cpp | 3 +- src/gui/UBTGWidgetTreeDelegate.cpp | 2 + src/gui/UBTeacherGuideDelegate.cpp | 1 + src/gui/UBTeacherGuideWidget.cpp | 2 + src/gui/UBTeacherGuideWidgetsTools.cpp | 2 + src/pdf-merger/CCITTFaxDecode.cpp | 2 + src/pdf-merger/DCTDecode.cpp | 2 + src/pdf-merger/JBIG2Decode.cpp | 1 + src/web/UBOEmbedParser.cpp | 2 + 35 files changed, 133 insertions(+), 68 deletions(-) diff --git a/src/adaptors/UBExportCFF.cpp b/src/adaptors/UBExportCFF.cpp index 741eb871..bc97a730 100644 --- a/src/adaptors/UBExportCFF.cpp +++ b/src/adaptors/UBExportCFF.cpp @@ -3,6 +3,7 @@ #include "document/UBDocumentProxy.h" #include "core/UBDocumentManager.h" #include "core/UBApplication.h" +#include "core/memcheck.h" UBExportCFF::UBExportCFF(QObject *parent) diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 51b8622e..980a6911 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -58,10 +58,10 @@ #include "UBBoardController.h" -#include "core/memcheck.h" - #include "document/UBDocumentController.h" +#include "core/memcheck.h" + UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardController* pBoardController) : QObject(container) , mKeyboardPalette(0) @@ -81,7 +81,9 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll , mPendingPanButtonPressed(false) , mPendingEraseButtonPressed(false) , mpPageNavigWidget(NULL) +#ifdef USE_WEB_WIDGET , mpLibWidget(NULL) +#endif , mpCachePropWidget(NULL) , mpDownloadWidget(NULL) , mpDesktopLibWidget(NULL) @@ -132,7 +134,9 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() mpPageNavigWidget = new UBPageNavigationWidget(); +#ifdef USE_WEB_WIDGET mpLibWidget = new UBLibWidget(); +#endif mpCachePropWidget = new UBCachePropertiesWidget(); @@ -159,8 +163,11 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() mRightPalette->addTab(mpFeaturesWidget); //Do not show deprecated lib widget to prevent collisions. Uncomment to return lib widget -// mRightPalette->registerWidget(mpLibWidget); -// mRightPalette->addTab(mpLibWidget); + +#ifdef USE_WEB_WIDGET + mRightPalette->registerWidget(mpLibWidget); + mRightPalette->addTab(mpLibWidget); +#endif // The cache widget will be visible only if a cache is put on the page @@ -841,10 +848,10 @@ void UBBoardPaletteManager::addItemToLibrary() } QImage image = mPixmap.toImage(); - if(NULL != mpLibWidget) - { - mpLibWidget->libNavigator()->libraryWidget()->libraryController()->importImageOnLibrary(image); - } +#ifdef USE_WEB_WIDGET + mpLibWidget->libNavigator()->libraryWidget()->libraryController()->importImageOnLibrary(image); +#endif + } else { diff --git a/src/board/UBBoardPaletteManager.h b/src/board/UBBoardPaletteManager.h index 6a1c60a1..45b982de 100644 --- a/src/board/UBBoardPaletteManager.h +++ b/src/board/UBBoardPaletteManager.h @@ -43,6 +43,10 @@ class UBMainWindow; class UBApplicationController; class UBDockTeacherGuideWidget; +// Uncomment this to use old-styles lib paletter +// #define USE_WEB_WIDGET + + class UBBoardPaletteManager : public QObject { Q_OBJECT @@ -125,8 +129,12 @@ class UBBoardPaletteManager : public QObject /** The page navigator widget */ UBPageNavigationWidget* mpPageNavigWidget; + +#ifdef USE_WEB_WIDGET /** The library widget */ UBLibWidget* mpLibWidget; +#endif + /** The cache properties widget */ UBCachePropertiesWidget* mpCachePropWidget; diff --git a/src/board/UBFeaturesController.cpp b/src/board/UBFeaturesController.cpp index 5ab469a4..0c0679b2 100644 --- a/src/board/UBFeaturesController.cpp +++ b/src/board/UBFeaturesController.cpp @@ -18,6 +18,8 @@ #include "domain/UBGraphicsVideoItem.h" #include "domain/UBGraphicsWidgetItem.h" +#include "core/memcheck.h" + UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QString &realPath, UBFeatureElementType type) : virtualPath(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type) { @@ -67,12 +69,10 @@ void UBFeaturesController::initDirectoryTree() mLibShapesDirectoryPath = UBSettings::settings()->applicationShapeLibraryDirectory() ; trashDirectoryPath = UBSettings::userTrashDirPath(); - featuresList = new QList (); - QList tools = UBToolsManager::manager()->allTools(); - featuresList->append( UBFeature( QString(), QPixmap( ":images/libpalette/home.png" ), "root", QString() ) ); - currentElement = featuresList->at(0); + featuresList.append( UBFeature( QString(), QPixmap( ":images/libpalette/home.png" ), "root", QString() ) ); + currentElement = featuresList.at(0); appPath = rootPath + "/Applications"; audiosPath = rootPath + "/Audios"; @@ -85,30 +85,30 @@ void UBFeaturesController::initDirectoryTree() favoritePath = rootPath + "/Favorites"; audiosElement = UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath ); - featuresList->append( audiosElement ); + featuresList.append( audiosElement ); moviesElement = UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath ); - featuresList->append( moviesElement ); + featuresList.append( moviesElement ); picturesElement = UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath ); - featuresList->append( picturesElement ); - featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath ) ); + featuresList.append( picturesElement ); + featuresList.append( UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath ) ); flashElement = UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath ); - featuresList->append( flashElement ); + featuresList.append( flashElement ); interactElement = UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath ); - featuresList->append( interactElement ); - featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath ) ); + featuresList.append( interactElement ); + featuresList.append( UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath ) ); trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH ); - featuresList->append( trashElement ); + featuresList.append( trashElement ); favoriteElement = UBFeature( rootPath, QPixmap(":images/libpalette/FavoritesCategory.svg"), "Favorites", "favorites", FEATURE_FAVORITE ); - featuresList->append( favoriteElement ); + featuresList.append( favoriteElement ); loadFavoriteList(); foreach (UBToolsManager::UBToolDescriptor tool, tools) { - featuresList->append( UBFeature( appPath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) ); - if ( favoriteSet->find( tool.id ) != favoriteSet->end() ) + featuresList.append( UBFeature( appPath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) ); + if ( favoriteSet.find( tool.id ) != favoriteSet.end() ) { - featuresList->append( UBFeature( favoritePath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) ); + featuresList.append( UBFeature( favoritePath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) ); } } fileSystemScan( mUserInteractiveDirectoryPath, appPath ); @@ -163,10 +163,10 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt icon = QPixmap( thumbnailPath ); else icon = createThumbnail( fullFileName );*/ } - featuresList->append( UBFeature( currVirtualPath, icon, fileName, fullFileName, fileType ) ); - if ( favoriteSet->find( fullFileName ) != favoriteSet->end() ) + featuresList.append( UBFeature( currVirtualPath, icon, fileName, fullFileName, fileType ) ); + if ( favoriteSet.find( fullFileName ) != favoriteSet.end() ) { - featuresList->append( UBFeature( favoritePath, icon, fileName, fullFileName, fileType ) ); + featuresList.append( UBFeature( favoritePath, icon, fileName, fullFileName, fileType ) ); } if ( fileType == FEATURE_FOLDER ) @@ -179,7 +179,6 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt void UBFeaturesController::loadFavoriteList() { - favoriteSet = new QSet(); QFile file( UBSettings::userDataDirectory() + "/favorites.dat" ); if ( file.exists() ) { @@ -196,7 +195,7 @@ void UBFeaturesController::loadFavoriteList() UBFeature elem( favoritePath, thumbnailForFile( path ), fileName, path, fileTypeFromUrl(path) ); featuresList->append( elem );*/ - favoriteSet->insert( path ); + favoriteSet.insert( path ); } } } @@ -207,8 +206,8 @@ void UBFeaturesController::saveFavoriteList() file.resize(0); file.open(QIODevice::WriteOnly); QDataStream out(&file); - out << favoriteSet->size(); - for ( QSet::iterator it = favoriteSet->begin(); it != favoriteSet->end(); ++it ) + out << favoriteSet.size(); + for ( QSet::iterator it = favoriteSet.begin(); it != favoriteSet.end(); ++it ) { out << (*it); } @@ -218,12 +217,12 @@ void UBFeaturesController::saveFavoriteList() UBFeature UBFeaturesController::addToFavorite( const QUrl &path ) { QString filePath = fileNameFromUrl( path ); - if ( favoriteSet->find( filePath ) == favoriteSet->end() ) + if ( favoriteSet.find( filePath ) == favoriteSet.end() ) { QFileInfo fileInfo( filePath ); QString fileName = fileInfo.fileName(); UBFeature elem( favoritePath, thumbnailForFile( filePath ), fileName, filePath, fileTypeFromUrl(filePath) ); - favoriteSet->insert( filePath ); + favoriteSet.insert( filePath ); saveFavoriteList(); return elem; } @@ -233,9 +232,9 @@ UBFeature UBFeaturesController::addToFavorite( const QUrl &path ) void UBFeaturesController::removeFromFavorite( const QUrl &path ) { QString filePath = fileNameFromUrl( path ); - if ( favoriteSet->find( filePath ) != favoriteSet->end() ) + if ( favoriteSet.find( filePath ) != favoriteSet.end() ) { - favoriteSet->erase( favoriteSet->find( filePath ) ); + favoriteSet.erase( favoriteSet.find( filePath ) ); saveFavoriteList(); } } diff --git a/src/board/UBFeaturesController.h b/src/board/UBFeaturesController.h index 914b6a7d..163e6c6c 100644 --- a/src/board/UBFeaturesController.h +++ b/src/board/UBFeaturesController.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,7 @@ public: UBFeaturesController(QWidget *parentWidget); virtual ~UBFeaturesController(); - QList * getFeatures()const { return featuresList; } + const QList & getFeatures()const { return featuresList; } const QString& getRootPath()const { return rootPath; } @@ -87,7 +88,7 @@ private: static UBFeatureElementType fileTypeFromUrl( const QString &path ); - QList *featuresList; + QList featuresList; UBFeature *rootElement; QString mUserAudioDirectoryPath; @@ -128,7 +129,7 @@ private: UBFeature flashElement; UBFeature shapesElement; - QSet *favoriteSet; + QSet favoriteSet; }; diff --git a/src/customWidgets/UBActionableWidget.cpp b/src/customWidgets/UBActionableWidget.cpp index 78d8ea6b..25c1809e 100644 --- a/src/customWidgets/UBActionableWidget.cpp +++ b/src/customWidgets/UBActionableWidget.cpp @@ -18,6 +18,8 @@ #include "UBActionableWidget.h" +#include "core/memcheck.h" + UBActionableWidget::UBActionableWidget(QWidget *parent, const char *name):QWidget(parent) , mShowActions(false) { diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp index cbc0b842..cf7f8489 100644 --- a/src/customWidgets/UBMediaWidget.cpp +++ b/src/customWidgets/UBMediaWidget.cpp @@ -16,6 +16,8 @@ #include "globals/UBGlobals.h" #include "UBMediaWidget.h" +#include "core/memcheck.h" + /** * \brief Constructor * @param type as the media type diff --git a/src/domain/UBAbstractUndoCommand.cpp b/src/domain/UBAbstractUndoCommand.cpp index fe623acc..fc5d9fdf 100644 --- a/src/domain/UBAbstractUndoCommand.cpp +++ b/src/domain/UBAbstractUndoCommand.cpp @@ -15,6 +15,8 @@ #include "UBAbstractUndoCommand.h" +#include "core/memcheck.h" + UBAbstractUndoCommand::UBAbstractUndoCommand() { // NOOP diff --git a/src/domain/UBAngleWidget.cpp b/src/domain/UBAngleWidget.cpp index 542a7eed..7be0bf39 100644 --- a/src/domain/UBAngleWidget.cpp +++ b/src/domain/UBAngleWidget.cpp @@ -1,6 +1,8 @@ #include "UBAngleWidget.h" #include +#include "core/memcheck.h" + UBAngleWidget::UBAngleWidget(QWidget *parent) : QWidget(parent) { diff --git a/src/domain/UBGraphicsItemUndoCommand.cpp b/src/domain/UBGraphicsItemUndoCommand.cpp index d027c1f0..bc8c4c82 100644 --- a/src/domain/UBGraphicsItemUndoCommand.cpp +++ b/src/domain/UBGraphicsItemUndoCommand.cpp @@ -19,12 +19,12 @@ #include "UBGraphicsScene.h" -#include "core/memcheck.h" - #include "core/UBApplication.h" #include "board/UBBoardController.h" +#include "core/memcheck.h" + UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet& pRemovedItems, const QSet& pAddedItems) : mScene(pScene) diff --git a/src/domain/UBGraphicsMediaItem.cpp b/src/domain/UBGraphicsMediaItem.cpp index 9342cb66..dd19e275 100644 --- a/src/domain/UBGraphicsMediaItem.cpp +++ b/src/domain/UBGraphicsMediaItem.cpp @@ -23,10 +23,10 @@ #include "board/UBBoardController.h" -#include "core/memcheck.h" - #include "frameworks/UBFileSystemUtils.h" +#include "core/memcheck.h" + bool UBGraphicsMediaItem::sIsMutedByDefault = false; UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent) diff --git a/src/domain/UBGraphicsStrokesGroup.cpp b/src/domain/UBGraphicsStrokesGroup.cpp index ac7aadf0..a7f658dd 100644 --- a/src/domain/UBGraphicsStrokesGroup.cpp +++ b/src/domain/UBGraphicsStrokesGroup.cpp @@ -1,5 +1,7 @@ #include "UBGraphicsStrokesGroup.h" +#include "core/memcheck.h" + UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsItemGroup(parent) { mDelegate = new UBGraphicsItemDelegate(this, 0, true, true); diff --git a/src/domain/UBGraphicsTextItemDelegate.cpp b/src/domain/UBGraphicsTextItemDelegate.cpp index 8c132325..2a911fbf 100644 --- a/src/domain/UBGraphicsTextItemDelegate.cpp +++ b/src/domain/UBGraphicsTextItemDelegate.cpp @@ -24,9 +24,10 @@ #include "domain/UBGraphicsDelegateFrame.h" #include "core/UBSettings.h" -#include "core/memcheck.h" #include "board/UBBoardController.h" +#include "core/memcheck.h" + const int UBGraphicsTextItemDelegate::sMinPixelSize = 8; const int UBGraphicsTextItemDelegate::sMinPointSize = 8; diff --git a/src/domain/ubgraphicsgroupcontaineritem.cpp b/src/domain/ubgraphicsgroupcontaineritem.cpp index 0a706099..22990d79 100644 --- a/src/domain/ubgraphicsgroupcontaineritem.cpp +++ b/src/domain/ubgraphicsgroupcontaineritem.cpp @@ -6,6 +6,8 @@ #include "domain/ubgraphicsgroupcontaineritemdelegate.h" #include "domain/UBGraphicsScene.h" +#include "core/memcheck.h" + UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent) : QGraphicsItemGroup(parent) { diff --git a/src/domain/ubgraphicsgroupcontaineritemdelegate.cpp b/src/domain/ubgraphicsgroupcontaineritemdelegate.cpp index ff763520..19997a2b 100644 --- a/src/domain/ubgraphicsgroupcontaineritemdelegate.cpp +++ b/src/domain/ubgraphicsgroupcontaineritemdelegate.cpp @@ -8,9 +8,10 @@ #include "domain/UBGraphicsDelegateFrame.h" #include "domain/ubgraphicsgroupcontaineritem.h" -#include "core/memcheck.h" #include "board/UBBoardController.h" +#include "core/memcheck.h" + UBGraphicsGroupContainerItemDelegate::UBGraphicsGroupContainerItemDelegate(QGraphicsItem *pDelegated, QObject *parent) : UBGraphicsItemDelegate(pDelegated, parent), mDestroyGroupButton(0) diff --git a/src/frameworks/UBCoreGraphicsScene.cpp b/src/frameworks/UBCoreGraphicsScene.cpp index 68ffed2d..9eb68db7 100644 --- a/src/frameworks/UBCoreGraphicsScene.cpp +++ b/src/frameworks/UBCoreGraphicsScene.cpp @@ -15,12 +15,13 @@ #include "UBCoreGraphicsScene.h" -#include "core/memcheck.h" #include "domain/UBGraphicsAudioItem.h" #include "domain/UBGraphicsVideoItem.h" #include "domain/UBGraphicsMediaItem.h" #include "domain/UBGraphicsWidgetItem.h" +#include "core/memcheck.h" + UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent) : QGraphicsScene ( parent ) { diff --git a/src/gui/UBDockDownloadWidget.cpp b/src/gui/UBDockDownloadWidget.cpp index 4ce9d07e..a09ab966 100644 --- a/src/gui/UBDockDownloadWidget.cpp +++ b/src/gui/UBDockDownloadWidget.cpp @@ -17,6 +17,8 @@ #include "globals/UBGlobals.h" +#include "core/memcheck.h" + UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent, name) , mpLayout(NULL) , mpDLWidget(NULL) diff --git a/src/gui/UBDockTeacherGuideWidget.cpp b/src/gui/UBDockTeacherGuideWidget.cpp index f8ad4f43..0c4d5c4a 100644 --- a/src/gui/UBDockTeacherGuideWidget.cpp +++ b/src/gui/UBDockTeacherGuideWidget.cpp @@ -19,6 +19,8 @@ #include "UBDockTeacherGuideWidget.h" #include "UBTeacherGuideWidget.h" +#include "core/memcheck.h" + UBDockTeacherGuideWidget::UBDockTeacherGuideWidget(QWidget* parent, const char* name): UBDockPaletteWidget(parent,name) diff --git a/src/gui/UBFeaturesActionBar.cpp b/src/gui/UBFeaturesActionBar.cpp index 09b7af82..ac009c48 100644 --- a/src/gui/UBFeaturesActionBar.cpp +++ b/src/gui/UBFeaturesActionBar.cpp @@ -1,4 +1,5 @@ #include "UBFeaturesActionBar.h" +#include "core/memcheck.h" UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWidget* parent, const char* name ) : QWidget (parent) , featuresController(controller) diff --git a/src/gui/UBFeaturesWidget.cpp b/src/gui/UBFeaturesWidget.cpp index 58a691ae..f7492339 100644 --- a/src/gui/UBFeaturesWidget.cpp +++ b/src/gui/UBFeaturesWidget.cpp @@ -6,6 +6,7 @@ #include "core/UBApplication.h" #include "core/UBDownloadManager.h" #include "globals/UBGlobals.h" +#include "core/memcheck.h" UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) { @@ -500,6 +501,16 @@ void UBFeatureProperties::onAddToPage() UBFeatureProperties::~UBFeatureProperties() { + if ( mpOrigPixmap ) + { + delete mpOrigPixmap; + mpOrigPixmap = NULL; + } + if ( mpElement ) + { + delete mpElement; + mpElement = NULL; + } } UBFeatureItemButton::UBFeatureItemButton(QWidget *parent, const char *name):QPushButton(parent) @@ -519,19 +530,19 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const return QVariant(); if (role == Qt::DisplayRole) - return featuresList->at(index.row()).getName(); + return featuresList.at(index.row()).getName(); else if (role == Qt::DecorationRole) { - return QIcon( featuresList->at(index.row()).getThumbnail() ); + return QIcon( featuresList.at(index.row()).getThumbnail() ); } else if (role == Qt::UserRole) { - return featuresList->at(index.row()).getUrl(); + return featuresList.at(index.row()).getUrl(); } else if (role == Qt::UserRole + 1) { //return featuresList->at(index.row()).getType(); - UBFeature f = featuresList->at(index.row()); + UBFeature f = featuresList.at(index.row()); return QVariant::fromValue( f ); } @@ -607,17 +618,17 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act void UBFeaturesModel::addItem( const UBFeature &item ) { - beginInsertRows( QModelIndex(), featuresList->size(), featuresList->size() ); - featuresList->push_back( item ); + beginInsertRows( QModelIndex(), featuresList.size(), featuresList.size() ); + featuresList.push_back( item ); endInsertRows(); } void UBFeaturesModel::deleteFavoriteItem( const QString &path ) { - for ( int i = 0; i < featuresList->size(); ++i ) + for ( int i = 0; i < featuresList.size(); ++i ) { - if ( !QString::compare( featuresList->at(i).getFullPath(), path, Qt::CaseInsensitive ) && - !QString::compare( featuresList->at(i).getUrl(), "/root/favorites", Qt::CaseInsensitive ) ) + if ( !QString::compare( featuresList.at(i).getFullPath(), path, Qt::CaseInsensitive ) && + !QString::compare( featuresList.at(i).getUrl(), "/root/favorites", Qt::CaseInsensitive ) ) { removeRow( i, QModelIndex() ); return; @@ -629,11 +640,11 @@ bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent { if ( row < 0 ) return false; - if ( row + count > featuresList->size() ) + if ( row + count > featuresList.size() ) return false; beginRemoveRows( parent, row, row + count - 1 ); //featuresList->remove( row, count ); - featuresList->erase( featuresList->begin() + row, featuresList->begin() + row + count ); + featuresList.erase( featuresList.begin() + row, featuresList.begin() + row + count ); endRemoveRows(); return true; } @@ -642,11 +653,11 @@ bool UBFeaturesModel::removeRow( int row, const QModelIndex & parent ) { if ( row < 0 ) return false; - if ( row >= featuresList->size() ) + if ( row >= featuresList.size() ) return false; beginRemoveRows( parent, row, row ); //featuresList->remove( row ); - featuresList->erase( featuresList->begin() + row ); + featuresList.erase( featuresList.begin() + row ); endRemoveRows(); return true; } @@ -698,7 +709,7 @@ int UBFeaturesModel::rowCount(const QModelIndex &parent) const if (parent.isValid()) return 0; else - return featuresList->size(); + return featuresList.size(); } diff --git a/src/gui/UBFeaturesWidget.h b/src/gui/UBFeaturesWidget.h index 5c9762c6..7e19cb47 100644 --- a/src/gui/UBFeaturesWidget.h +++ b/src/gui/UBFeaturesWidget.h @@ -181,9 +181,9 @@ public: Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } - void setFeaturesList( QList *flist ) { featuresList = flist; } + void setFeaturesList(const QList &flist ) { featuresList = flist; } private: - QList *featuresList; + QList featuresList; }; class UBFeaturesProxyModel : public QSortFilterProxyModel diff --git a/src/gui/UBLibItemProperties.cpp b/src/gui/UBLibItemProperties.cpp index 4d2eada3..86c9233d 100644 --- a/src/gui/UBLibItemProperties.cpp +++ b/src/gui/UBLibItemProperties.cpp @@ -18,12 +18,13 @@ #include "core/UBApplication.h" #include "core/UBDownloadManager.h" -#include "core/memcheck.h" #include "frameworks/UBFileSystemUtils.h" #include "globals/UBGlobals.h" +#include "core/memcheck.h" + /** * \brief Constructor diff --git a/src/gui/UBLibNavigatorWidget.cpp b/src/gui/UBLibNavigatorWidget.cpp index 5974c4ea..d7b50551 100644 --- a/src/gui/UBLibNavigatorWidget.cpp +++ b/src/gui/UBLibNavigatorWidget.cpp @@ -16,10 +16,11 @@ #include "UBLibWidget.h" #include "core/UBApplication.h" -#include "core/memcheck.h" #include "globals/UBGlobals.h" +#include "core/memcheck.h" + static int lowBoundForSlider = 40; static int topBoundForSlider = 120; static int tickIntervalForSlider = 10; diff --git a/src/gui/UBLibPathViewer.cpp b/src/gui/UBLibPathViewer.cpp index fe31b290..9ca91d82 100644 --- a/src/gui/UBLibPathViewer.cpp +++ b/src/gui/UBLibPathViewer.cpp @@ -20,10 +20,11 @@ #include "core/UBApplication.h" #include "board/UBBoardController.h" -#include "core/memcheck.h" #include "core/UBDownloadManager.h" #include "board/UBBoardPaletteManager.h" +#include "core/memcheck.h" + /** * \brief Constructor * @param parent as the parent widget diff --git a/src/gui/UBLibWebView.cpp b/src/gui/UBLibWebView.cpp index ac6e11a5..a70cbcdc 100644 --- a/src/gui/UBLibWebView.cpp +++ b/src/gui/UBLibWebView.cpp @@ -1,7 +1,6 @@ #include #include "core/UBApplication.h" -#include "core/memcheck.h" #include "board/UBBoardController.h" @@ -9,7 +8,7 @@ #include "UBLibWebView.h" - +#include "core/memcheck.h" UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent) , mpView(NULL) diff --git a/src/gui/UBLibWidget.cpp b/src/gui/UBLibWidget.cpp index 9765bae4..5fbfad49 100644 --- a/src/gui/UBLibWidget.cpp +++ b/src/gui/UBLibWidget.cpp @@ -17,10 +17,11 @@ #include "UBLibWidget.h" #include "core/UBApplication.h" -#include "core/memcheck.h" #include "globals/UBGlobals.h" +#include "core/memcheck.h" + /** * \brief Constructor * @param parent as the parent widget diff --git a/src/gui/UBPageNavigationWidget.cpp b/src/gui/UBPageNavigationWidget.cpp index 6ff72dd8..4d751ccd 100644 --- a/src/gui/UBPageNavigationWidget.cpp +++ b/src/gui/UBPageNavigationWidget.cpp @@ -14,12 +14,13 @@ */ #include "UBPageNavigationWidget.h" #include "core/UBApplication.h" -#include "core/memcheck.h" #include "board/UBBoardController.h" #include "globals/UBGlobals.h" +#include "core/memcheck.h" + /** * \brief Constructor * @param parent as the parent widget diff --git a/src/gui/UBTGWidgetTreeDelegate.cpp b/src/gui/UBTGWidgetTreeDelegate.cpp index 928beac9..1b3754f6 100644 --- a/src/gui/UBTGWidgetTreeDelegate.cpp +++ b/src/gui/UBTGWidgetTreeDelegate.cpp @@ -7,6 +7,8 @@ #include #include "UBTGWidgetTreeDelegate.h" +#include "core/memcheck.h" + UBTGWidgetTreeDelegate::UBTGWidgetTreeDelegate(QObject *parent) : QStyledItemDelegate(parent) { diff --git a/src/gui/UBTeacherGuideDelegate.cpp b/src/gui/UBTeacherGuideDelegate.cpp index 33dba6fe..fd98606a 100644 --- a/src/gui/UBTeacherGuideDelegate.cpp +++ b/src/gui/UBTeacherGuideDelegate.cpp @@ -1,4 +1,5 @@ #include "UBTeacherGuideDelegate.h" +#include "core/memcheck.h" UBTeacherGuideDelegate::UBTeacherGuideDelegate() { diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 9fc0fdcd..1d571274 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -40,6 +40,8 @@ #include "document/UBDocumentProxy.h" #include "document/UBDocumentController.h" +#include "core/memcheck.h" + #define UBTG_SEPARATOR_FIXED_HEIGHT 3 diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index 73b89276..adf91d11 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -32,6 +32,8 @@ #include "frameworks/UBFileSystemUtils.h" +#include "core/memcheck.h" + /*************************************************************************** * class UBAddItem * diff --git a/src/pdf-merger/CCITTFaxDecode.cpp b/src/pdf-merger/CCITTFaxDecode.cpp index 1b9310c9..5c1ab0af 100644 --- a/src/pdf-merger/CCITTFaxDecode.cpp +++ b/src/pdf-merger/CCITTFaxDecode.cpp @@ -16,6 +16,8 @@ #include #include "CCITTFaxDecode.h" +#include "core/memcheck.h" + using namespace merge_lib; bool CCITTFaxDecode::encode(std::string & decoded) diff --git a/src/pdf-merger/DCTDecode.cpp b/src/pdf-merger/DCTDecode.cpp index 603926c5..392c4862 100644 --- a/src/pdf-merger/DCTDecode.cpp +++ b/src/pdf-merger/DCTDecode.cpp @@ -16,6 +16,8 @@ #include #include "DCTDecode.h" +#include "core/memcheck.h" + using namespace merge_lib; bool DCTDecode::encode(std::string & decoded) diff --git a/src/pdf-merger/JBIG2Decode.cpp b/src/pdf-merger/JBIG2Decode.cpp index 6ef248d0..f6e601de 100644 --- a/src/pdf-merger/JBIG2Decode.cpp +++ b/src/pdf-merger/JBIG2Decode.cpp @@ -15,6 +15,7 @@ #include #include "JBIG2Decode.h" +#include "core/memcheck.h" using namespace merge_lib; diff --git a/src/web/UBOEmbedParser.cpp b/src/web/UBOEmbedParser.cpp index 1cb8e1f8..786d2883 100644 --- a/src/web/UBOEmbedParser.cpp +++ b/src/web/UBOEmbedParser.cpp @@ -24,6 +24,8 @@ #include "UBOEmbedParser.h" +#include "core/memcheck.h" + UBOEmbedParser::UBOEmbedParser(QObject *parent, const char* name) { Q_UNUSED(parent);