Skip to content

Commit 2db2085

Browse files
committed
bug_746577 Problem locating unresolvable @ref in case of a MSC image
- get better filename and line number (in case of inline image the end of the inline image) - in case link don't exist don't create it
1 parent 3fd7dd8 commit 2db2085

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

src/docparser.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2079,11 +2079,16 @@ IDocNodeASTPtr validatingParseText(IDocParser &parserIntf,const QCString &input)
20792079
return ast;
20802080
}
20812081

2082-
IDocNodeASTPtr createRef(IDocParser &parserIntf,const QCString &target,const QCString &context)
2082+
IDocNodeASTPtr createRef(IDocParser &parserIntf,const QCString &target,const QCString &context, const QCString &srcFile, int srcLine )
20832083
{
20842084
DocParser *parser = dynamic_cast<DocParser*>(&parserIntf);
20852085
assert(parser!=0);
20862086
if (parser==0) return 0;
2087+
if (!srcFile.isEmpty())
2088+
{
2089+
parser->context.fileName = srcFile;
2090+
parser->tokenizer.setLineNr(srcLine);
2091+
}
20872092
return std::make_unique<DocNodeAST>(DocRef(parser,0,target,context));
20882093
}
20892094

src/docparser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ IDocNodeASTPtr validatingParseDoc(IDocParser &parserIntf,const QCString &fileNam
8787
*/
8888
IDocNodeASTPtr validatingParseText(IDocParser &parser,const QCString &input);
8989

90-
IDocNodeASTPtr createRef(IDocParser &parser,const QCString &target,const QCString &context);
90+
IDocNodeASTPtr createRef(IDocParser &parser,const QCString &target,const QCString &context, const QCString &srcFile = "", int srcLine = -1);
9191

9292
//--------------------------------------------------------------------------------
9393

src/msc.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
static const int maxCmdLine = 40960;
3030

3131
static bool convertMapFile(TextStream &t,const QCString &mapName,const QCString &relPath,
32-
const QCString &context)
32+
const QCString &context,const QCString &srcFile,int srcLine)
3333
{
3434
std::ifstream f = Portable::openInputStream(mapName);
3535
if (!f.is_open())
@@ -63,17 +63,22 @@ static bool convertMapFile(TextStream &t,const QCString &mapName,const QCString
6363
if (y2<y1) { int temp=y2; y2=y1; y1=temp; }
6464
if (x2<x1) { int temp=x2; x2=x1; x1=temp; }
6565

66-
t << "<area href=\"";
6766

67+
bool link = false;
6868
if ( isRef )
6969
{
7070
// handle doxygen \ref tag URL reference
7171

7272
auto parser { createDocParser() };
73-
auto dfAst { createRef( *parser.get(), url, context ) };
73+
auto dfAst { createRef( *parser.get(), url, context, srcFile, srcLine) };
7474
auto dfAstImpl = dynamic_cast<const DocNodeAST*>(dfAst.get());
7575
const DocRef *df = std::get_if<DocRef>(&dfAstImpl->root);
7676
t << externalRef(relPath,df->ref(),TRUE);
77+
if (!df->file().isEmpty() || !df->anchor().isEmpty())
78+
{
79+
link = true;
80+
t << "<area href=\"";
81+
}
7782
if (!df->file().isEmpty())
7883
{
7984
QCString fn = df->file();
@@ -87,11 +92,16 @@ static bool convertMapFile(TextStream &t,const QCString &mapName,const QCString
8792
}
8893
else
8994
{
95+
link = true;
96+
t << "<area href=\"";
9097
t << url;
9198
}
92-
t << "\" shape=\"rect\" coords=\""
93-
<< x1 << "," << y1 << "," << x2 << "," << y2 << "\""
94-
<< " alt=\"\"/>\n";
99+
if (link)
100+
{
101+
t << "\" shape=\"rect\" coords=\""
102+
<< x1 << "," << y1 << "," << x2 << "," << y2 << "\""
103+
<< " alt=\"\"/>\n";
104+
}
95105
}
96106
}
97107

@@ -204,7 +214,7 @@ static QCString getMscImageMapFromFile(const QCString& inFile, const QCString& /
204214
return "";
205215

206216
TextStream t;
207-
convertMapFile(t, outFile, relPath, context);
217+
convertMapFile(t, outFile, relPath, context, srcFile, srcLine);
208218

209219
Dir().remove(outFile.str());
210220

0 commit comments

Comments
 (0)