[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [umbrello] umbrello/codegenerators: umbrello/codegenerators/codegenobjectwithtextblocks.cpp
From: Oliver Kellogg <okellogg () users ! sourceforge ! net>
Date: 2014-10-27 23:15:11
Message-ID: E1XitVH-0006p3-D5 () scm ! kde ! org
[Download RAW message or body]
Git commit 5e260d82a338d59ab5565fbe76e1dc5e248de135 by Oliver Kellogg.
Committed on 27/10/2014 at 22:47.
Pushed by okellogg into branch 'master'.
umbrello/codegenerators/codegenobjectwithtextblocks.cpp
- In function getCodeBlockWithComments, if addTextBlock(codeBlock) returns
false then delete codeBlock before returning (otherwise codeBlock leaks.)
- Make cosmetic adjustments to follow Umbrello coding style.
M +18 -28 umbrello/codegenerators/codegenobjectwithtextblocks.cpp
http://commits.kde.org/umbrello/5e260d82a338d59ab5565fbe76e1dc5e248de135
diff --git a/umbrello/codegenerators/codegenobjectwithtextblocks.cpp \
b/umbrello/codegenerators/codegenobjectwithtextblocks.cpp index 45b88fa..13f42fc \
100644
--- a/umbrello/codegenerators/codegenobjectwithtextblocks.cpp
+++ b/umbrello/codegenerators/codegenobjectwithtextblocks.cpp
@@ -59,13 +59,10 @@ bool CodeGenObjectWithTextBlocks::addTextBlock(TextBlock* \
add_object) QString tag = add_object->getTag();
// assign a tag if one doesn't already exist
- if (tag.isEmpty())
- {
+ if (tag.isEmpty()) {
tag = getUniqueTag();
add_object->setTag(tag);
- }
- else
- {
+ } else {
// if it has a tag, check to see that it is not in some other parent object
// IF it is then we will need to remove it FIRST before adding to new parent
CodeDocument * parentDoc = add_object->getParentDocument();
@@ -101,8 +98,7 @@ bool CodeGenObjectWithTextBlocks::removeTextBlock (TextBlock * \
remove_object) }
else {
// may be hiding in child hierarchical codeblock
- foreach (TextBlock* tb, m_textblockVector)
- {
+ foreach (TextBlock* tb, m_textblockVector) {
HierarchicalCodeBlock * hb = dynamic_cast<HierarchicalCodeBlock*>(tb);
if (hb && hb->removeTextBlock(remove_object))
return true;
@@ -149,11 +145,9 @@ CodeGenObjectWithTextBlocks * \
CodeGenObjectWithTextBlocks::findParentObjectForTa if (tag.isEmpty())
return (CodeGenObjectWithTextBlocks*) NULL;
- if (!findTextBlockByTag(tag))
- {
+ if (!findTextBlockByTag(tag)) {
// may be hiding in child hierarchical codeblock
- foreach (TextBlock* tb, m_textblockVector)
- {
+ foreach (TextBlock* tb, m_textblockVector) {
HierarchicalCodeBlock * hb = dynamic_cast<HierarchicalCodeBlock*>(tb);
if (hb) {
CodeGenObjectWithTextBlocks* cgowtb = \
dynamic_cast<CodeGenObjectWithTextBlocks*>(hb); @@ -189,11 +183,9 @@ \
HierarchicalCodeBlock * CodeGenObjectWithTextBlocks::getHierarchicalCodeBlock (c \
codeBlock->setTag(tag);
codeBlock->setComment(CodeGenFactory::newCodeComment(m_pCodeDoc));
// don't write empty comments out
- if(comment.isEmpty())
+ if (comment.isEmpty())
codeBlock->getComment()->setWriteOutText(false);
-
- if(!addTextBlock(codeBlock))
- {
+ if (!addTextBlock(codeBlock)) {
delete codeBlock;
return (HierarchicalCodeBlock*) NULL;
}
@@ -223,10 +215,12 @@ CodeBlockWithComments * \
CodeGenObjectWithTextBlocks::getCodeBlockWithComments (c codeBlock->setTag(tag);
codeBlock->setComment(CodeGenFactory::newCodeComment(m_pCodeDoc));
// don't write empty comments out
- if(comment.isEmpty())
+ if (comment.isEmpty())
codeBlock->getComment()->setWriteOutText(false);
- if(!addTextBlock(codeBlock))
+ if (!addTextBlock(codeBlock)) {
+ delete codeBlock;
return (CodeBlockWithComments*) NULL;
+ }
}
codeBlock->setOverallIndentationLevel (indentLevel);
codeBlock->getComment()->setText(comment);
@@ -249,12 +243,11 @@ CodeComment * \
CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeComment (const Q CodeComment * \
codeComment = dynamic_cast<CodeComment*>(tBlock); bool createdCodeComment = false;
- if(!codeComment) {
+ if (!codeComment) {
createdCodeComment = true;
codeComment = CodeGenFactory::newCodeComment(m_pCodeDoc);
codeComment->setTag(tag);
- if(!addTextBlock(codeComment))
- {
+ if (!addTextBlock(codeComment)) {
delete codeComment;
return 0; // hmm. total failure.., was there a preexisting comment with \
this tag?? lets return null }
@@ -262,7 +255,7 @@ CodeComment * \
CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeComment (const Q
codeComment->setText(text);
if (createdCodeComment) {
- if(!text.isEmpty())
+ if (!text.isEmpty())
codeComment->setWriteOutText(true); // set to visible, if we created
else
codeComment->setWriteOutText(false); // set to not visible, if we \
created @@ -294,22 +287,19 @@ CodeBlockWithComments * \
CodeGenObjectWithTextBlocks::addOrUpdateTaggedCodeBlockW createdCodeBlock = true;
codeBlock = newCodeBlockWithComments();
codeBlock->setTag(tag);
- if(!addTextBlock(codeBlock))
- {
+ if (!addTextBlock(codeBlock)) {
delete codeBlock;
return 0; // hmm. total failure.., was there a preexisting codeblock \
with this tag?? lets return null }
}
// ONLY update IF we are forcing the update of user blocks OR it is an \
"AutoGenerated" Block
- if (forceUserBlockUpdate || codeBlock->contentType() == \
CodeBlock::AutoGenerated)
- {
+ if (forceUserBlockUpdate || codeBlock->contentType() == \
CodeBlock::AutoGenerated) { codeBlock->setText(text);
codeBlock->getComment()->setText(ctext);
// if we created this from scratch, make it write out only when the block \
isnt empty
- if (createdCodeBlock)
- {
+ if (createdCodeBlock) {
if (!ctext.isEmpty())
codeBlock->getComment()->setWriteOutText(true);
else
@@ -482,7 +472,7 @@ void CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode \
(QDomElement & roo } else
loadCheckForChildrenOK = true;
- } else if(name == QLatin1String("codeblock")) {
+ } else if (name == QLatin1String("codeblock")) {
CodeBlock * block = newCodeBlock();
block->loadFromXMI(element);
if (!addTextBlock(block)) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic