summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2019-10-13 21:53:12 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2019-10-13 21:53:12 (GMT)
commit79f6a43c5fbd1f28f2fbdaa642cf42a0079b5be6 (patch)
tree0e2b6137d67b3d6a2acef5aff30eb1ff28d83536 /src
parentd2b8ae16cb99621827f5dd860222c27e629f5a7f (diff)
downloadDoxygen-79f6a43c5fbd1f28f2fbdaa642cf42a0079b5be6.zip
Doxygen-79f6a43c5fbd1f28f2fbdaa642cf42a0079b5be6.tar.gz
Doxygen-79f6a43c5fbd1f28f2fbdaa642cf42a0079b5be6.tar.bz2
Fix lifetime issue for Entry objects.
Diffstat (limited to 'src')
-rw-r--r--src/entry.cpp35
-rw-r--r--src/entry.h5
-rw-r--r--src/scanner.l4
3 files changed, 32 insertions, 12 deletions
diff --git a/src/entry.cpp b/src/entry.cpp
index ec3c736..8ec7846 100644
--- a/src/entry.cpp
+++ b/src/entry.cpp
@@ -240,6 +240,32 @@ void Entry::copyToSubEntry(const std::unique_ptr<Entry> &current)
m_sublist.push_back(std::move(copy));
}
+void Entry::moveFromSubEntry(const Entry *child,std::unique_ptr<Entry> &moveTo)
+{
+ auto it = std::find_if(m_sublist.begin(),m_sublist.end(),
+ [child](const std::unique_ptr<Entry>&elem) { return elem.get()==child; });
+ if (it!=m_sublist.end())
+ {
+ moveTo = std::move(*it);
+ m_sublist.erase(it);
+ }
+ else
+ {
+ moveTo.reset();
+ }
+}
+
+void Entry::removeSubEntry(const Entry *e)
+{
+ auto it = std::find_if(m_sublist.begin(),m_sublist.end(),
+ [e](const std::unique_ptr<Entry>&elem) { return elem.get()==e; });
+ if (it!=m_sublist.end())
+ {
+ m_sublist.erase(it);
+ }
+}
+
+
void Entry::reset()
{
static bool entryCallGraph = Config_getBool(CALL_GRAPH);
@@ -335,14 +361,5 @@ void Entry::addSpecialListItem(const char *listName,int itemId)
sli->append(ili);
}
-void Entry::removeSubEntry(Entry *e)
-{
- auto it = std::find_if(m_sublist.begin(),m_sublist.end(),
- [e](const std::unique_ptr<Entry>&elem) { return elem.get()==e; });
- if (it!=m_sublist.end())
- {
- m_sublist.erase(it);
- }
-}
//------------------------------------------------------------------
diff --git a/src/entry.h b/src/entry.h
index 091e81b..c078936 100644
--- a/src/entry.h
+++ b/src/entry.h
@@ -223,6 +223,9 @@ class Entry
void moveToSubEntryAndRefresh(Entry* &e);
void moveToSubEntryAndRefresh(std::unique_ptr<Entry> &e);
+ /*! take \a child of of to list of children and move it into \a moveTo */
+ void moveFromSubEntry(const Entry *child,std::unique_ptr<Entry> &moveTo);
+
/*! make a copy of \a e and add it as a child to this entry */
void copyToSubEntry (Entry* e);
void copyToSubEntry (const std::unique_ptr<Entry> &e);
@@ -230,7 +233,7 @@ class Entry
/*! Removes entry \a e from the list of children.
* The entry will be deleted if found.
*/
- void removeSubEntry(Entry *e);
+ void removeSubEntry(const Entry *e);
/*! Restore the state of this Entry to the default value it has
* at construction time.
diff --git a/src/scanner.l b/src/scanner.l
index fe20543..4ed4a62 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -5305,9 +5305,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
else
{
current->endBodyLine=yyLineNr;
-
+ // take previous out of current_root and move it into current
current.swap(tempEntry); // remember current
- current.reset(previous); // and temporarily switch to the previous entry
+ current_root->moveFromSubEntry(previous,current);
previous = 0;
docBlockContext = SkipCurlyEndDoc;