diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index 707416e5a..13ce2719a 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -258,7 +258,10 @@ ApplicationBase::parse_cmd (int &argc, char **argv) } } - m_config_file_to_write = tl::to_string (QDir (tl::to_qstring (m_appdata_path)).absoluteFilePath (QString::fromUtf8 ("klayoutrc"))); + m_config_file_to_write.clear (); + if (! m_appdata_path.empty ()) { + m_config_file_to_write = tl::to_string (QDir (tl::to_qstring (m_appdata_path)).absoluteFilePath (QString::fromUtf8 ("klayoutrc"))); + } // Hint: the order is reverse in the sense that the first one wins ... for (std::vector ::const_iterator p = m_klayout_path.end (); p != m_klayout_path.begin (); ) { @@ -733,10 +736,12 @@ ApplicationBase::init_app () std::vector global_modules = scan_global_modules (); m_load_macros.insert (m_load_macros.begin (), global_modules.begin (), global_modules.end ()); + size_t local_folders = (lay::get_appdata_path ().empty () ? 0 : 1); + for (std::vector ::const_iterator p = m_klayout_path.begin (); p != m_klayout_path.end (); ++p) { - if (p == m_klayout_path.begin ()) { + if (p - m_klayout_path.begin () < local_folders) { mc->add_path (*p, tl::to_string (QObject::tr ("Local")), std::string (), false); - } else if (m_klayout_path.size () == 2) { + } else if (m_klayout_path.size () == 1 + local_folders) { mc->add_path (*p, tl::to_string (QObject::tr ("Global")), std::string (), true); } else { mc->add_path (*p, tl::to_string (QObject::tr ("Global")) + " - " + *p, std::string (), true); diff --git a/src/lay/lay/layHelpSource.cc b/src/lay/lay/layHelpSource.cc index beb1aa7c0..8889038e8 100644 --- a/src/lay/lay/layHelpSource.cc +++ b/src/lay/lay/layHelpSource.cc @@ -274,13 +274,18 @@ HelpSource::initialize_index () bool ok = false; const QString help_index_cache_file = QString::fromUtf8 ("help-index.xml"); - std::string per_user_cache_file = tl::to_string (QDir (tl::to_qstring (lay::ApplicationBase::instance ()->appdata_path ())).absoluteFilePath (help_index_cache_file)); + std::string per_user_cache_file; + if (! lay::ApplicationBase::instance ()->appdata_path ().empty ()) { + per_user_cache_file = tl::to_string (QDir (tl::to_qstring (lay::ApplicationBase::instance ()->appdata_path ())).absoluteFilePath (help_index_cache_file)); + } // Try to obtain the help index from the installation or application path std::vector cache_files; cache_files.push_back (tl::to_string (QDir (tl::to_qstring (lay::ApplicationBase::instance ()->inst_path ())).absoluteFilePath (help_index_cache_file))); - cache_files.push_back (per_user_cache_file); + if (! per_user_cache_file.empty ()) { + cache_files.push_back (per_user_cache_file); + } for (std::vector::const_iterator c = cache_files.begin (); ! ok && c != cache_files.end (); ++c) { @@ -307,7 +312,7 @@ HelpSource::initialize_index () } - if (! ok) { + if (! ok && ! per_user_cache_file.empty ()) { // If no index is found, create one in "per_user_cache_file" produce_index_file (per_user_cache_file); } diff --git a/src/lay/lay/layMacroController.cc b/src/lay/lay/layMacroController.cc index 41167c001..aa1c392b6 100644 --- a/src/lay/lay/layMacroController.cc +++ b/src/lay/lay/layMacroController.cc @@ -262,7 +262,7 @@ MacroController::drop_url (const std::string &path_or_url) macro->load_from (path); macro->set_file_path (path); - if (macro->is_autorun () || macro->show_in_menu ()) { + if ((macro->is_autorun () || macro->show_in_menu ()) && ! lay::ApplicationBase::instance ()->appdata_path ().empty ()) { // install macro permanently if (QMessageBox::question (mp_mw, diff --git a/src/lay/lay/laySystemPaths.cc b/src/lay/lay/laySystemPaths.cc index d43f8578f..236a4dca9 100644 --- a/src/lay/lay/laySystemPaths.cc +++ b/src/lay/lay/laySystemPaths.cc @@ -40,8 +40,9 @@ namespace lay std::string get_appdata_path () { - if (tl::has_env ("KLAYOUT_HOME")) { - return tl::get_env ("KLAYOUT_HOME"); + const char *klayout_home_env = "KLAYOUT_HOME"; + if (tl::has_env (klayout_home_env)) { + return tl::get_env (klayout_home_env); } QDir appdata_dir = QDir::homePath (); @@ -105,11 +106,18 @@ get_klayout_path () std::vector klayout_path; // generate the klayout path: the first component is always the appdata path - klayout_path.push_back (get_appdata_path ()); + std::string adp = get_appdata_path (); + if (! adp.empty ()) { + klayout_path.push_back (adp); + } - std::string env = tl::get_env ("KLAYOUT_PATH"); - if (! env.empty ()) { - split_path (env, klayout_path); + const char *klayout_path_env = "KLAYOUT_PATH"; + + if (tl::has_env (klayout_path_env)) { + std::string env = tl::get_env (klayout_path_env); + if (! env.empty ()) { + split_path (env, klayout_path); + } } else { klayout_path.push_back (tl::get_inst_path ()); }