|
28 | 28 | #include "doxygen.h" |
29 | 29 | #include "config.h" |
30 | 30 |
|
31 | | -static std::mutex g_tooltipsMutex; |
| 31 | +static std::mutex g_tooltipsFileMutex; |
| 32 | +static std::mutex g_tooltipsTipMutex; |
32 | 33 | static std::unordered_map<int, std::unordered_set<std::string> > g_tooltipsWrittenPerFile; |
33 | 34 |
|
34 | 35 | class TooltipManager::Private |
@@ -87,20 +88,34 @@ void TooltipManager::addTooltip(const Definition *d) |
87 | 88 |
|
88 | 89 | void TooltipManager::writeTooltips(OutputCodeList &ol) |
89 | 90 | { |
| 91 | + std::unordered_map<int, std::unordered_set<std::string> >::iterator it; |
90 | 92 | // critical section |
91 | | - std::lock_guard<std::mutex> lock(g_tooltipsMutex); |
92 | | - |
93 | | - int id = ol.id(); |
94 | | - auto it = g_tooltipsWrittenPerFile.find(id); |
95 | | - if (it==g_tooltipsWrittenPerFile.end()) // new file |
96 | 93 | { |
97 | | - it = g_tooltipsWrittenPerFile.insert(std::make_pair(id,std::unordered_set<std::string>())).first; |
| 94 | + std::lock_guard<std::mutex> lock(g_tooltipsFileMutex); |
| 95 | + |
| 96 | + int id = ol.id(); |
| 97 | + it = g_tooltipsWrittenPerFile.find(id); |
| 98 | + if (it==g_tooltipsWrittenPerFile.end()) // new file |
| 99 | + { |
| 100 | + it = g_tooltipsWrittenPerFile.insert(std::make_pair(id,std::unordered_set<std::string>())).first; |
| 101 | + } |
98 | 102 | } |
99 | 103 |
|
100 | 104 | for (const auto &[name,d] : p->tooltipInfo) |
101 | 105 | { |
102 | | - bool written = it->second.find(name)!=it->second.end(); |
103 | | - if (!written) // only write tooltips once |
| 106 | + bool written = false; |
| 107 | + |
| 108 | + // critical section |
| 109 | + { |
| 110 | + std::lock_guard<std::mutex> lock(g_tooltipsTipMutex); |
| 111 | + it->second.find(name)!=it->second.end(); |
| 112 | + if (!written) // only write tooltips once |
| 113 | + { |
| 114 | + it->second.insert(name); // remember we wrote this tooltip for the given file id |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + if (!written) |
104 | 119 | { |
105 | 120 | //printf("%p: writeTooltips(%s) ol=%d\n",this,name.c_str(),ol.id()); |
106 | 121 | DocLinkInfo docInfo; |
@@ -133,7 +148,6 @@ void TooltipManager::writeTooltips(OutputCodeList &ol) |
133 | 148 | defInfo, |
134 | 149 | declInfo |
135 | 150 | ); |
136 | | - it->second.insert(name); // remember we wrote this tooltip for the given file id |
137 | 151 | } |
138 | 152 | } |
139 | 153 | } |
|
0 commit comments