MCPcopy Create free account
hub / github.com/KLayout/klayout / initialize_index

Method initialize_index

src/lay/lay/layHelpSource.cc:268–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268void
269HelpSource::initialize_index ()
270{
271 try {
272
273 tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (QObject::tr ("Initializing help index")));
274
275 bool ok = false;
276
277 int qt = int (QT_VERSION >> 16);
278 QString help_index_cache_file = tl::to_qstring (tl::sprintf ("help-index-%s-qt%d.xml.gz", lay::Version::version (), qt));
279
280 std::string per_user_cache_file;
281 if (! lay::ApplicationBase::instance ()->appdata_path ().empty ()) {
282 per_user_cache_file = tl::to_string (QDir (tl::to_qstring (lay::ApplicationBase::instance ()->appdata_path ())).absoluteFilePath (help_index_cache_file));
283 }
284
285 // Try to obtain the help index from the installation or application path
286
287 std::vector<std::string> cache_files;
288 cache_files.push_back (tl::to_string (QDir (tl::to_qstring (lay::ApplicationBase::instance ()->inst_path ())).absoluteFilePath (help_index_cache_file)));
289 if (! per_user_cache_file.empty ()) {
290 cache_files.push_back (per_user_cache_file);
291 }
292
293 for (std::vector<std::string>::const_iterator c = cache_files.begin (); ! ok && c != cache_files.end (); ++c) {
294
295 try {
296 tl::XMLFileSource in (*c);
297 help_index_structure.parse (in, *this);
298 if (m_klayout_version == lay::ApplicationBase::version ()) {
299 if (tl::verbosity () >= 10) {
300 tl::info << tl::to_string (tr ("Help index initialized from ")) << *c;
301 }
302 ok = true;
303 } else {
304 if (tl::verbosity () >= 10) {
305 tl::warn << tl::to_string (tr ("Help index ignored (wrong version) from ")) << *c;
306 }
307 }
308 } catch (tl::Exception &ex) {
309 tl::warn << ex.msg ();
310 } catch (std::runtime_error &ex) {
311 tl::warn << ex.what ();
312 } catch (...) {
313 tl::warn << "unknown error.";
314 }
315
316 }
317
318 if (! ok && ! per_user_cache_file.empty ()) {
319 // If no index is found, create one in "per_user_cache_file"
320 produce_index_file (per_user_cache_file);
321 }
322
323 } catch (tl::Exception &ex) {
324
325 m_index.clear ();

Callers

nothing calls this directly

Calls 15

verbosityFunction · 0.85
to_qstringFunction · 0.85
inst_pathMethod · 0.80
msgMethod · 0.80
whatMethod · 0.80
versionFunction · 0.70
instanceFunction · 0.70
to_stringFunction · 0.50
trFunction · 0.50
sprintfFunction · 0.50
QDirClass · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected