Skip to content

Commit e9abc43

Browse files
authored
Merge pull request #909 from letsfindaway/refactor-fixme-clang
Refactor: avoid serious clang warnings
2 parents c8d6d70 + ea61aca commit e9abc43

17 files changed

+78
-68
lines changed

src/adaptors/UBCFFSubsetAdaptor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,10 @@ UBGraphicsGroupContainerItem *UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbGro
12351235
if (pStrokesGroup->childItems().count())
12361236
mCurrentScene->addItem(pStrokesGroup);
12371237
else
1238+
{
12381239
delete pStrokesGroup;
1240+
pStrokesGroup = nullptr;
1241+
}
12391242

12401243
if (pStrokesGroup)
12411244
{

src/api/UBWidgetUniboardAPI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ bool UBWidgetUniboardAPI::ProcessDropEvent(QGraphicsSceneDragDropEvent *event)
565565

566566
if (!UBFileSystemUtils::copyFile(fileName, destFileName)) {
567567
qDebug() << "can't copy from" << fileName << "to" << destFileName;
568+
delete dropMimeData;
568569
return false;
569570
}
570571
downloaded = true;

src/core/UBDocumentManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ QString UBDocumentManager::importFileFilter(bool notUbx)
151151

152152
QFileInfoList UBDocumentManager::importUbx(const QString &Incomingfile, const QString &destination)
153153
{
154-
UBImportDocumentSetAdaptor *docSetAdaptor;
154+
UBImportDocumentSetAdaptor *docSetAdaptor = nullptr;
155155
foreach (UBImportAdaptor *curAdaptor, mImportAdaptors) {
156156
docSetAdaptor = qobject_cast<UBImportDocumentSetAdaptor*>(curAdaptor);
157157
if (docSetAdaptor) {

src/core/UBPersistenceManager.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ UBPersistenceManager::UBPersistenceManager(QObject *pParent)
103103
mDocumentTreeStructureModel = new UBDocumentTreeModel(this);
104104
createDocumentProxiesStructure();
105105

106-
emit proxyListChanged();
107-
108106
mThread = new QThread;
109107
mWorker = new UBPersistenceWorker();
110108
mWorker->moveToThread(mThread);
@@ -632,9 +630,7 @@ std::shared_ptr<UBDocumentProxy> UBPersistenceManager::createDocument(const QStr
632630
} else if (processInteractiveReplacementDialog(doc) == QDialog::Accepted) {
633631
addDoc = true;
634632
}
635-
if (addDoc) {
636-
emit proxyListChanged();
637-
} else {
633+
if (!addDoc) {
638634
deleteDocument(doc);
639635
doc = 0;
640636
}
@@ -710,7 +706,6 @@ std::shared_ptr<UBDocumentProxy> UBPersistenceManager::createDocumentFromDir(con
710706
}
711707
if (addDoc) {
712708
UBMetadataDcSubsetAdaptor::persist(doc);
713-
emit proxyListChanged();
714709
emit documentCreated(doc);
715710
} else {
716711
deleteDocument(doc);
@@ -762,8 +757,6 @@ std::shared_ptr<UBDocumentProxy> UBPersistenceManager::duplicateDocument(std::sh
762757

763758
copy->setPageCount(sceneCount(copy));
764759

765-
emit proxyListChanged();
766-
767760
emit documentCreated(copy);
768761

769762
return copy;

src/core/UBPersistenceManager.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ class UBPersistenceManager : public QObject
158158
bool isSceneInCached(std::shared_ptr<UBDocumentProxy>proxy, int index) const;
159159

160160
signals:
161-
162-
void proxyListChanged();
163-
164161
void documentCreated(std::shared_ptr<UBDocumentProxy> pDocumentProxy);
165162
void documentMetadataChanged(std::shared_ptr<UBDocumentProxy> pDocumentProxy);
166163

src/desktop/UBCustomCaptureWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void UBCustomCaptureWindow::mouseReleaseEvent ( QMouseEvent * event )
131131
event->accept();
132132

133133
// do not accept very small selection
134-
if (!(mSelectionBand->geometry().width() < 6 && mSelectionBand->geometry().height() < 6))
134+
if (mSelectionBand && !(mSelectionBand->geometry().width() < 6 && mSelectionBand->geometry().height() < 6))
135135
{
136136
accept();
137137
}

src/desktop/UBDesktopPalette.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ void UBDesktopPalette::showHideClick(bool checked)
137137

138138
void UBDesktopPalette::updateShowHideState(bool pShowEnabled)
139139
{
140-
if (mShowHideAction)
141-
mShowHideAction->setChecked(pShowEnabled);
140+
mShowHideAction->setChecked(pShowEnabled);
142141

143142
if (mShowHideAction->isChecked())
144143
mShowHideAction->setToolTip(tr("Show Board on Secondary Screen"));

src/document/UBDocumentController.cpp

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,11 @@ QModelIndex UBDocumentTreeModel::goTo(const QString &dir)
12221222
if (!searchingNode) {
12231223
UBDocumentTreeNode *newChild = new UBDocumentTreeNode(UBDocumentTreeNode::Catalog, curLevelName);
12241224
parentIndex = addNode(newChild, parentIndex);
1225+
1226+
if (!parentIndex.isValid())
1227+
{
1228+
delete newChild;
1229+
}
12251230
}
12261231
}
12271232

@@ -1266,7 +1271,10 @@ void UBDocumentTreeModel::addDocument(std::shared_ptr<UBDocumentProxy> pProxyDat
12661271
lParent = goTo(docGroupName);
12671272
}
12681273

1269-
addNode(freeNode, lParent);
1274+
if (!addNode(freeNode, lParent).isValid())
1275+
{
1276+
delete freeNode;
1277+
}
12701278
}
12711279

12721280
void UBDocumentTreeModel::addNewDocument(std::shared_ptr<UBDocumentProxy> pProxyData, const QModelIndex &pParent)
@@ -1281,7 +1289,14 @@ QModelIndex UBDocumentTreeModel::addCatalog(const QString &pName, const QModelIn
12811289
}
12821290

12831291
UBDocumentTreeNode *catalogNode = new UBDocumentTreeNode(UBDocumentTreeNode::Catalog, pName);
1284-
return addNode(catalogNode, pParent);
1292+
QModelIndex index = addNode(catalogNode, pParent);
1293+
1294+
if (!index.isValid())
1295+
{
1296+
delete catalogNode;
1297+
}
1298+
1299+
return index;
12851300
}
12861301

12871302
void UBDocumentTreeModel::setNewName(const QModelIndex &index, const QString &newName)
@@ -1569,7 +1584,12 @@ void UBDocumentTreeView::dragMoveEvent(QDragMoveEvent *event)
15691584
if (!docModel || !docModel->isDocument(targetIndex) || docModel->inTrash(targetIndex)) {
15701585
event->ignore();
15711586
event->setDropAction(Qt::IgnoreAction);
1572-
docModel->setHighLighted(QModelIndex());
1587+
1588+
if (docModel)
1589+
{
1590+
docModel->setHighLighted(QModelIndex());
1591+
}
1592+
15731593
acceptIt = false;
15741594
} else {
15751595
docModel->setHighLighted(targetIndex);
@@ -1605,8 +1625,8 @@ void UBDocumentTreeView::dropEvent(QDropEvent *event)
16051625
bool isUBPage = event->mimeData()->hasFormat(UBApplication::mimeTypeUniboardPage);
16061626

16071627
//issue 1629 - NNE - 20131212
1608-
bool targetIsInTrash = docModel->inTrash(targetIndex) || docModel->trashIndex() == targetIndex;
1609-
bool targetIsInMyDocuments = docModel->inMyDocuments(targetIndex) || docModel->myDocumentsIndex() == targetIndex;
1628+
bool targetIsInTrash = docModel && (docModel->inTrash(targetIndex) || docModel->trashIndex() == targetIndex);
1629+
bool targetIsInMyDocuments = docModel && (docModel->inMyDocuments(targetIndex) || docModel->myDocumentsIndex() == targetIndex);
16101630

16111631
if (!targetIsInMyDocuments && !targetIsInTrash)
16121632
return;
@@ -1829,15 +1849,15 @@ QWidget *UBDocumentTreeItemDelegate::createEditor(QWidget *parent, const QStyleO
18291849
const UBDocumentTreeModel *docModel = 0;
18301850

18311851
const UBSortFilterProxyModel *proxy = dynamic_cast<const UBSortFilterProxyModel*>(index.model());
1852+
QModelIndex sourceIndex;
18321853

18331854
if(proxy){
18341855
docModel = dynamic_cast<UBDocumentTreeModel*>(proxy->sourceModel());
1856+
sourceIndex = proxy->mapToSource(index);
18351857
}else{
18361858
docModel = dynamic_cast<const UBDocumentTreeModel*>(index.model());
18371859
}
18381860

1839-
QModelIndex sourceIndex = proxy->mapToSource(index);
1840-
18411861
if (docModel)
18421862
{
18431863
mExistingFileNames = docModel->nodeNameList(sourceIndex.parent());
@@ -2225,6 +2245,8 @@ void UBDocumentController::setupViews()
22252245
adaptor->setAssociatedAction(currentExportAction);
22262246
}
22272247

2248+
bool exportMenuAttached = false;
2249+
22282250
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
22292251
foreach (QObject* menuWidget, mMainWindow->actionExport->associatedObjects())
22302252
#else
@@ -2239,9 +2261,15 @@ void UBDocumentController::setupViews()
22392261
tb->setPopupMode(QToolButton::InstantPopup);
22402262

22412263
tb->setMenu(exportMenu);
2264+
exportMenuAttached = true;
22422265
}
22432266
}
22442267

2268+
if (!exportMenuAttached)
2269+
{
2270+
delete exportMenu;
2271+
}
2272+
22452273
#ifdef Q_OS_OSX
22462274
mMainWindow->actionDelete->setShortcut(QKeySequence(Qt::Key_Backspace));
22472275
#else

src/domain/UBGraphicsItemDelegate.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -853,11 +853,14 @@ void UBGraphicsItemDelegate::setLocked(bool pLocked)
853853

854854
void UBGraphicsItemDelegate::updateFrame()
855855
{
856-
if (mFrame && !mFrame->scene() && mDelegated->scene())
857-
mDelegated->scene()->addItem(mFrame);
856+
if (mFrame)
857+
{
858+
if (!mFrame->scene() && mDelegated->scene())
859+
mDelegated->scene()->addItem(mFrame);
858860

859-
mFrame->setAntiScale(mAntiScaleRatio);
860-
mFrame->positionHandles();
861+
mFrame->setAntiScale(mAntiScaleRatio);
862+
mFrame->positionHandles();
863+
}
861864
}
862865

863866
void UBGraphicsItemDelegate::updateButtons(bool showUpdated)

src/domain/UBGraphicsMediaItem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool UBGraphicsMediaItem::sIsMutedByDefault = false;
4949
*/
5050
UBGraphicsMediaItem* UBGraphicsMediaItem::createMediaItem(const QUrl &pMediaFileUrl, QGraphicsItem* parent)
5151
{
52-
UBGraphicsMediaItem * mediaItem;
52+
UBGraphicsMediaItem * mediaItem = nullptr;
5353

5454
QString mediaPath = pMediaFileUrl.toString();
5555
if ("" == mediaPath)

src/domain/UBGraphicsMediaItemDelegate.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,21 @@ void UBGraphicsMediaItemDelegate::positionHandles()
185185
mToolBarItem->show();
186186

187187
mToolBarItem->setRect(toolBarRect);
188-
}
189188

190-
int toolBarButtonsWidth = 0;
191-
foreach (DelegateButton* button, mToolBarButtons)
192-
toolBarButtonsWidth += button->boundingRect().width() + mToolBarItem->getElementsPadding();
189+
int toolBarButtonsWidth = 0;
190+
foreach (DelegateButton* button, mToolBarButtons)
191+
toolBarButtonsWidth += button->boundingRect().width() + mToolBarItem->getElementsPadding();
193192

194-
QRectF mediaItemRect = mMediaControl->rect();
195-
mediaItemRect.setWidth(mediaItem->boundingRect().width() - toolBarButtonsWidth);
196-
mediaItemRect.setHeight(mToolBarItem->boundingRect().height());
197-
mMediaControl->setRect(mediaItemRect);
193+
QRectF mediaItemRect = mMediaControl->rect();
194+
mediaItemRect.setWidth(mediaItem->boundingRect().width() - toolBarButtonsWidth);
195+
mediaItemRect.setHeight(mToolBarItem->boundingRect().height());
196+
mMediaControl->setRect(mediaItemRect);
198197

199-
mToolBarItem->positionHandles();
200-
mMediaControl->positionHandles();
198+
mToolBarItem->positionHandles();
199+
mMediaControl->positionHandles();
201200

202-
if (mediaItem)
203201
mToolBarItem->show();
202+
}
204203
}
205204

206205
void UBGraphicsMediaItemDelegate::remove(bool canUndo)

src/gui/UBThumbnailWidget.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ void UBThumbnailWidget::refreshScene()
158158
{
159159
QGraphicsItem* item = mGraphicItems.at(i);
160160

161+
if (!item)
162+
continue;
163+
161164
UBSceneThumbnailPixmap *thumbnail = dynamic_cast<UBSceneThumbnailPixmap*>(item);
162165
if (thumbnail)
163166
thumbnail->setSceneIndex(i);

src/gui/UBToolWidget.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,6 @@ QPixmap* UBToolWidget::sClosePixmap = 0;
5353
QPixmap* UBToolWidget::sUnpinPixmap = 0;
5454

5555

56-
UBToolWidget::UBToolWidget(const QUrl& pUrl, QWidget *pParent)
57-
: QWidget(pParent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
58-
, mWebView(0)
59-
, mToolWidget(0)
60-
, mShouldMoveWidget(false)
61-
, mContentMargin(0)
62-
, mFrameWidth(0)
63-
64-
{
65-
int widgetType = UBGraphicsWidgetItem::widgetType(pUrl);
66-
if (widgetType == UBWidgetType::Apple) // NOTE @letsfindaway obsolete
67-
mToolWidget = new UBGraphicsAppleWidgetItem(pUrl);
68-
else if (widgetType == UBWidgetType::W3C)
69-
mToolWidget = new UBGraphicsW3CWidgetItem(pUrl);
70-
else
71-
qDebug() << "UBToolWidget::UBToolWidget: Unknown widget Type";
72-
73-
initialize();
74-
}
75-
7656
UBToolWidget::UBToolWidget(UBGraphicsWidgetItem *pWidget, QWidget *pParent)
7757
: QWidget(pParent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)
7858
, mWebView(0)

src/gui/UBToolWidget.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class UBToolWidget : public QWidget
4747
Q_OBJECT;
4848

4949
public:
50-
UBToolWidget(const QUrl& pUrl, QWidget* pParent = 0);
5150
UBToolWidget(UBGraphicsWidgetItem* pWidget, QWidget* pParent = 0);
5251
virtual ~UBToolWidget();
5352

src/web/UBEmbedController.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,17 @@ void UBEmbedController::importWidgetInLibrary(const QDir& pSourceDir) const
262262
}
263263

264264

265-
if (UBApplication::boardController &&
266-
UBApplication::boardController->activeScene())
265+
if (UBApplication::boardController)
267266
{
268-
UBApplication::boardController->addW3cWidget(QUrl::fromLocalFile(widgetLibraryPath), QPointF());
269-
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
270-
}
267+
if (UBApplication::boardController->activeScene())
268+
{
269+
UBApplication::boardController->addW3cWidget(QUrl::fromLocalFile(widgetLibraryPath), QPointF());
270+
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
271+
}
271272

272-
UBFeaturesController* featuresController = UBApplication::boardController->paletteManager()->featuresWidget()->getFeaturesController();
273-
featuresController->addUserWidgetToLibrary(widgetLibraryPath, mTrapFlashUi->widgetNameLineEdit->text());
273+
UBFeaturesController* featuresController = UBApplication::boardController->paletteManager()->featuresWidget()->getFeaturesController();
274+
featuresController->addUserWidgetToLibrary(widgetLibraryPath, mTrapFlashUi->widgetNameLineEdit->text());
275+
}
274276
}
275277

276278

src/web/UBWebController.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,12 @@ void UBWebController::loadUrl(const QUrl& url)
715715
WebView* UBWebController::createNewTab()
716716
{
717717
if (mCurrentWebBrowser)
718+
{
718719
UBApplication::applicationController->showInternet();
720+
return mCurrentWebBrowser->tabWidget()->createTab();
721+
}
719722

720-
return mCurrentWebBrowser->tabWidget()->createTab();
723+
return nullptr;
721724
}
722725

723726

src/web/simplebrowser/WBHistory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void WBHistoryManager::clear()
274274
m_fullSave = true;
275275
m_saveTimer->changeOccurred();
276276
m_saveTimer->saveIfNeccessary();
277-
historyReset();
277+
emit historyReset();
278278
}
279279

280280
void WBHistoryManager::loadSettings()

0 commit comments

Comments
 (0)