From ab51a2eb24e75ae79bf3e3213ca0d8a80a6e97bb Mon Sep 17 00:00:00 2001 From: "Victor \"multun\" Collod" Date: Sun, 26 Apr 2020 19:35:55 -0700 Subject: [PATCH 1/3] fix uninitialized variable uses I did a valgrind run to try and figure out why it OpenBoard crashes from time to time, and found these two uninitialized variable uses. --- src/document/UBDocumentController.cpp | 1 + src/domain/UBGraphicsStrokesGroup.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 03d676fb..e01611d8 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -345,6 +345,7 @@ UBDocumentTreeNode *UBDocumentTreeNode::previousSibling() UBDocumentTreeModel::UBDocumentTreeModel(QObject *parent) : QAbstractItemModel(parent) , mRootNode(0) + , mCurrentNode(nullptr) { UBDocumentTreeNode *rootNode = new UBDocumentTreeNode(UBDocumentTreeNode::Catalog, "root"); diff --git a/src/domain/UBGraphicsStrokesGroup.cpp b/src/domain/UBGraphicsStrokesGroup.cpp index 8ce08a2e..75d04dad 100644 --- a/src/domain/UBGraphicsStrokesGroup.cpp +++ b/src/domain/UBGraphicsStrokesGroup.cpp @@ -35,7 +35,10 @@ #include "core/memcheck.h" UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent) - :QGraphicsItemGroup(parent), UBGraphicsItem() + : QGraphicsItemGroup(parent) + , UBGraphicsItem() + , debugTextEnabled(false) // set to true to get a graphical display of strokes' Z-levels + , mDebugText(nullptr) { setDelegate(new UBGraphicsItemDelegate(this, 0, GF_COMMON | GF_RESPECT_RATIO @@ -49,9 +52,6 @@ UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent) setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsMovable, true); - - mDebugText = NULL; - debugTextEnabled = false; // set to true to get a graphical display of strokes' Z-levels } UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup() From 038f9ed07bc450dac1f930b4a42a0ad9a7bcfad1 Mon Sep 17 00:00:00 2001 From: "Victor \"multun\" Collod" Date: Sun, 3 May 2020 22:05:46 -0700 Subject: [PATCH 2/3] initialise mDrawWithCompass in UBGraphicsScene Detected using valgrind --- src/domain/UBGraphicsScene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 13be73d7..a76578df 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -337,8 +337,9 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta , magniferDisplayViewWidget(0) , mZLayerController(new UBZLayerController(this)) , mpLastPolygon(NULL) - , mCurrentPolygon(0) , mTempPolygon(NULL) + , mDrawWithCompass(false) + , mCurrentPolygon(0) , mSelectionFrame(0) { UBCoreGraphicsScene::setObjectName("BoardScene"); From a21fc24b753e7f1dd978fe93f1d9ac214909b05c Mon Sep 17 00:00:00 2001 From: "Victor \"multun\" Collod" Date: Sun, 3 May 2020 23:44:12 -0700 Subject: [PATCH 3/3] initialize isResizing in UBGraphicsDelegateFrame --- src/domain/UBGraphicsDelegateFrame.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/domain/UBGraphicsDelegateFrame.cpp b/src/domain/UBGraphicsDelegateFrame.cpp index 571491e7..36334510 100644 --- a/src/domain/UBGraphicsDelegateFrame.cpp +++ b/src/domain/UBGraphicsDelegateFrame.cpp @@ -67,6 +67,7 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega , mFlippedY(false) , mMirrorX(false) , mMirrorY(false) + , mResizing(false) , mTitleBarHeight(hasTitleBar ? 20 :0) , mNominalTitleBarHeight(hasTitleBar ? 20:0) {