mirror of https://github.com/KLayout/klayout.git
Fixed #112 (Salt package repo relative paths)
This patch also includes: * A segfault fixed that happend on some errors * package URL's are resolved relative to the salt mine URL if one is given.
This commit is contained in:
parent
3495f9c698
commit
1e2f8a0ce5
|
|
@ -140,9 +140,9 @@ public:
|
|||
/**
|
||||
* @brief Loads the salt from a "salt mine" stream
|
||||
*/
|
||||
void load (tl::InputStream &s)
|
||||
void load (const std::string &p, tl::InputStream &s)
|
||||
{
|
||||
m_root.load (s);
|
||||
m_root.load (p, s);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -481,14 +481,12 @@ SaltGrain::from_path (const std::string &path)
|
|||
}
|
||||
|
||||
tl::InputStream *
|
||||
SaltGrain::stream_from_url (std::string &url_in)
|
||||
SaltGrain::stream_from_url (std::string &url)
|
||||
{
|
||||
if (url_in.empty ()) {
|
||||
if (url.empty ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("No download link available")));
|
||||
}
|
||||
|
||||
std::string url = url_in;
|
||||
|
||||
// base relative URL's on the salt mine URL
|
||||
if (url.find ("http:") != 0 && url.find ("https:") != 0 && url.find ("file:") != 0 && !url.empty() && url[0] != '/' && url[0] != '\\' && lay::SaltController::instance ()) {
|
||||
|
||||
|
|
@ -500,7 +498,7 @@ SaltGrain::stream_from_url (std::string &url_in)
|
|||
}
|
||||
sami_url.setPath (path_comp.join (QString::fromUtf8 ("/")));
|
||||
|
||||
url_in = tl::to_string (sami_url.toString ());
|
||||
url = tl::to_string (sami_url.toString ());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -318,11 +318,11 @@ SaltGrains::load (const std::string &p)
|
|||
}
|
||||
|
||||
void
|
||||
SaltGrains::load (tl::InputStream &p)
|
||||
SaltGrains::load (const std::string &p, tl::InputStream &s)
|
||||
{
|
||||
m_url.clear ();
|
||||
m_url = p;
|
||||
|
||||
tl::XMLStreamSource source (p);
|
||||
tl::XMLStreamSource source (s);
|
||||
s_xml_struct.parse (source, *this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,8 +201,9 @@ public:
|
|||
|
||||
/**
|
||||
* @brief Loads the grain collection from the given input stream
|
||||
* "url" is used as the source URL.
|
||||
*/
|
||||
void load (tl::InputStream &p);
|
||||
void load (const std::string &p, tl::InputStream &s);
|
||||
|
||||
/**
|
||||
* @brief Saves the grain collection to the given file
|
||||
|
|
|
|||
|
|
@ -700,7 +700,7 @@ BEGIN_PROTECTED
|
|||
if (m_salt_mine_reader.get ()) {
|
||||
|
||||
lay::Salt new_mine;
|
||||
new_mine.load (*m_salt_mine_reader);
|
||||
new_mine.load (m_salt_mine_url, *m_salt_mine_reader);
|
||||
m_salt_mine = new_mine;
|
||||
|
||||
}
|
||||
|
|
@ -977,10 +977,13 @@ SaltManagerDialog::get_remote_grain_info (lay::SaltGrain *g, SaltGrainDetailsTex
|
|||
details->setHtml (html);
|
||||
|
||||
std::string url = g->url ();
|
||||
m_downloaded_grain_reader.reset (SaltGrain::stream_from_url (url));
|
||||
m_downloaded_grain.reset (new SaltGrain ());
|
||||
m_downloaded_grain->set_url (url);
|
||||
|
||||
// NOTE: stream_from_url may modify the URL, hence we set it again
|
||||
m_downloaded_grain_reader.reset (SaltGrain::stream_from_url (url));
|
||||
m_downloaded_grain->set_url (url);
|
||||
|
||||
tl::InputHttpStream *http = dynamic_cast<tl::InputHttpStream *> (m_downloaded_grain_reader->base ());
|
||||
if (http) {
|
||||
// async reading on HTTP
|
||||
|
|
@ -1038,7 +1041,7 @@ SaltManagerDialog::show_error (tl::Exception &ex)
|
|||
"</body>"
|
||||
"</html>"
|
||||
)
|
||||
.arg (tl::to_qstring (m_downloaded_grain->url ()))
|
||||
.arg (tl::to_qstring (m_downloaded_grain.get () ? m_downloaded_grain->url () : ""))
|
||||
.arg (tl::to_qstring (tl::escaped_to_html (ex.msg ())));
|
||||
mp_downloaded_target->setHtml (html);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue