Skip to content

Commit c686197

Browse files
committed
issue #8753 qhp file corrupt when subsection with no parent section
Decoupled the section level logic from the open/close logic.
1 parent 8bbce64 commit c686197

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/qhp.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static QCString makeRef(const QCString & withoutExtension, const QCString & anch
5353
return result+"#"+anchor;
5454
}
5555

56-
Qhp::Qhp() : m_prevSectionLevel(0), m_sectionLevel(0), m_skipMainPageSection(FALSE)
56+
Qhp::Qhp() : m_prevSectionLevel(0), m_sectionLevel(0), m_skipMainPageSection(FALSE), m_openClose(0)
5757
{
5858
m_doc.setIndentLevel(0);
5959
m_toc.setIndentLevel(2);
@@ -139,6 +139,7 @@ void Qhp::initialize()
139139
m_prevSectionTitle = getFullProjectName();
140140
m_prevSectionLevel = 1;
141141
m_sectionLevel = 1;
142+
m_openClose = 1;
142143

143144
m_index.open("keywords");
144145
m_files.open("files");
@@ -148,10 +149,11 @@ void Qhp::finalize()
148149
{
149150
// Finish TOC
150151
handlePrevSection();
151-
for (int i = m_prevSectionLevel; i > 0; i--)
152+
for (int i = m_openClose; i > 0; i--)
152153
{
153154
m_toc.close("section");
154155
}
156+
m_openClose = 0;
155157
m_toc.close("toc");
156158
m_doc.insert(m_toc);
157159

@@ -213,6 +215,7 @@ void Qhp::addContentsItem(bool /*isDir*/, const QCString & name,
213215
for (; diff > 0; diff--)
214216
{
215217
m_toc.close("section");
218+
m_openClose -=1;
216219
}
217220
}
218221

@@ -326,6 +329,7 @@ void Qhp::handlePrevSection()
326329
{
327330
// Section with children
328331
m_toc.open("section", attributes);
332+
m_openClose +=1;
329333
}
330334
else
331335
{

src/qhp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class Qhp : public IndexIntf
6363

6464
int m_prevSectionLevel;
6565
int m_sectionLevel;
66+
int m_openClose;
6667

6768
bool m_skipMainPageSection;
6869
};

0 commit comments

Comments
 (0)