@@ -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
12721280void 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
12871302void UBDocumentTreeModel::setNewName (const QModelIndex &index, const QString &newName)
@@ -2230,6 +2245,8 @@ void UBDocumentController::setupViews()
22302245 adaptor->setAssociatedAction (currentExportAction);
22312246 }
22322247
2248+ bool exportMenuAttached = false ;
2249+
22332250#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
22342251 foreach (QObject* menuWidget, mMainWindow ->actionExport ->associatedObjects ())
22352252#else
@@ -2244,9 +2261,15 @@ void UBDocumentController::setupViews()
22442261 tb->setPopupMode (QToolButton::InstantPopup);
22452262
22462263 tb->setMenu (exportMenu);
2264+ exportMenuAttached = true ;
22472265 }
22482266 }
22492267
2268+ if (!exportMenuAttached)
2269+ {
2270+ delete exportMenu;
2271+ }
2272+
22502273#ifdef Q_OS_OSX
22512274 mMainWindow ->actionDelete ->setShortcut (QKeySequence (Qt::Key_Backspace));
22522275#else
0 commit comments