Merge branch 'master' of https://github.com/fluxer/kdelibs into devinfo

This commit is contained in:
Ivailo Monev 2021-07-05 15:26:56 +00:00
commit e870ca49d9
8 changed files with 22 additions and 69 deletions

View file

@ -388,7 +388,6 @@ KLockFile::LockResult KLockFile::lock(LockFlags options)
KLockFile::LockResult result;
int hardErrors = 5;
int n = 5;
while(true) {
KDE_struct_stat st_buf;
// Try to create the lock file

View file

@ -76,9 +76,6 @@ class KLocalizedStringPrivate
QString postFormat (const QString &text,
const QString &lang,
const QString &ctxt) const;
static void notifyCatalogsUpdated (const QStringList &languages,
const QList<KCatalogName> &catalogs);
};
class KLocalizedStringPrivateStatics
@ -92,6 +89,7 @@ public:
}
};
K_GLOBAL_STATIC(KLocalizedStringPrivateStatics, staticsKLSP)
Q_GLOBAL_STATIC(QMutex, staticsKLSPLock)
KLocalizedString::KLocalizedString ()
: d(new KLocalizedStringPrivate)
@ -161,8 +159,6 @@ QString KLocalizedString::toString (const KLocale *locale,
QString KLocalizedStringPrivate::toString (const KLocale *locale,
const QString *catalogName) const
{
const KLocalizedStringPrivateStatics *s = staticsKLSP;
QMutexLocker lock(kLocaleMutex());
// Assure the message has been supplied.
@ -211,9 +207,7 @@ QString KLocalizedStringPrivate::toString (const KLocale *locale,
// Substitute placeholders in ordinary translation.
QString finalstr = substituteSimple(rawtrans);
// Post-format ordinary translation.
finalstr = postFormat(finalstr, lang, QString::fromLatin1(ctxt));
return finalstr;
return postFormat(finalstr, lang, QString::fromLatin1(ctxt));
}
QString KLocalizedStringPrivate::selectForEnglish () const
@ -363,17 +357,13 @@ QString KLocalizedStringPrivate::postFormat (const QString &text,
const QString &lang,
const QString &ctxt) const
{
QMutexLocker lock(staticsKLSPLock());
const KLocalizedStringPrivateStatics *s = staticsKLSP;
QMutexLocker lock(kLocaleMutex());
QString finalstr = text;
// Transform any semantic markup into visual formatting.
if (s->formatters.contains(lang)) {
finalstr = s->formatters[lang]->format(finalstr, ctxt);
return s->formatters[lang]->format(text, ctxt);
}
return finalstr;
return text;
}
static QString wrapNum (const QString &tag, const QString &numstr,
@ -547,19 +537,11 @@ KLocalizedString ki18ncp (const char* ctxt,
void KLocalizedString::notifyCatalogsUpdated (const QStringList &languages,
const QList<KCatalogName> &catalogs)
{
KLocalizedStringPrivate::notifyCatalogsUpdated(languages, catalogs);
}
void KLocalizedStringPrivate::notifyCatalogsUpdated (const QStringList &languages,
const QList<KCatalogName> &catalogs)
{
QMutexLocker lock(staticsKLSPLock());
if (staticsKLSP.isDestroyed()) {
return;
}
KLocalizedStringPrivateStatics *s = staticsKLSP;
// Very important: do not the mutex here.
//QMutexLocker lock(kLocaleMutex());
// Create visual formatters for each new language.
foreach (const QString &lang, languages) {
if (!s->formatters.contains(lang)) {

View file

@ -708,7 +708,7 @@ QString KMimeType::mainExtension() const
{
Q_D(const KMimeType);
Q_FOREACH(const QString& pattern, patterns()) {
Q_FOREACH(const QString& pattern, d->patterns()) {
// Skip if if looks like: README or *. or *.*
// or *.JP*G or *.JP?
if (pattern.startsWith(QLatin1String("*.")) &&

View file

@ -52,8 +52,6 @@ public:
HostInfoAgentPrivate();
QHostInfo lookupHost(const QString &hostName, const unsigned long timeout);
QHostInfo lookupCachedHostInfoFor(const QString &hostName);
void cacheLookup(const QHostInfo &hostName);
protected:
// reimplementation
@ -76,16 +74,6 @@ QHostInfo HostInfo::lookupHost(const QString &hostName, unsigned long timeout)
return hostInfoAgentPrivate->lookupHost(hostName, timeout);
}
QHostInfo HostInfo::lookupCachedHostInfoFor(const QString& hostName)
{
return hostInfoAgentPrivate->lookupCachedHostInfoFor(hostName);
}
void HostInfo::cacheLookup(const QHostInfo &info)
{
hostInfoAgentPrivate->cacheLookup(info);
}
HostInfoAgentPrivate::HostInfoAgentPrivate()
: m_dnsCache(HOSTINFO_CACHE_SIZE)
{
@ -106,7 +94,10 @@ QHostInfo HostInfoAgentPrivate::lookupHost(const QString &hostName, unsigned lon
}
// Look up the name in the DNS cache...
hostInfo = HostInfo::lookupCachedHostInfoFor(hostName);
const HostInfoPair* pair = m_dnsCache.object(hostName);
if (pair) {
hostInfo = pair->first;
}
if (!hostInfo.hostName().isEmpty() && hostInfo.error() == QHostInfo::NoError) {
return hostInfo;
}
@ -136,29 +127,15 @@ QHostInfo HostInfoAgentPrivate::lookupHost(const QString &hostName, unsigned lon
return m_dnsCache.object(hostName)->first;
}
void HostInfoAgentPrivate::cacheLookup(const QHostInfo &info)
void HostInfoAgentPrivate::lookupFinished(const QHostInfo &hostInfo)
{
if (info.hostName().isEmpty() || info.error() != QHostInfo::NoError) {
m_lookups.removeAll(hostInfo.lookupId());
if (hostInfo.hostName().isEmpty() || hostInfo.error() != QHostInfo::NoError) {
return;
}
QTime expiration = QTime::currentTime();
expiration.addSecs(HOSTINFO_EXPIRE_AFTER);
m_dnsCache.insert(info.hostName(), new HostInfoPair(info, expiration));
}
QHostInfo HostInfoAgentPrivate::lookupCachedHostInfoFor(const QString& hostName)
{
const HostInfoPair* pair = m_dnsCache.object(hostName);
if (pair) {
return pair->first;
}
return QHostInfo();
}
void HostInfoAgentPrivate::lookupFinished(const QHostInfo &hostInfo)
{
m_lookups.removeAll(hostInfo.lookupId());
cacheLookup(hostInfo);
m_dnsCache.insert(hostInfo.hostName(), new HostInfoPair(hostInfo, expiration));
}
void HostInfoAgentPrivate::timerEvent(QTimerEvent *event)

View file

@ -29,8 +29,6 @@ namespace KIO
namespace HostInfo
{
KIO_EXPORT QHostInfo lookupHost(const QString& hostName, unsigned long timeout);
KIO_EXPORT QHostInfo lookupCachedHostInfoFor(const QString& hostName);
KIO_EXPORT void cacheLookup(const QHostInfo& info);
}
}

View file

@ -722,9 +722,9 @@ protected:
/**
* Performs a DNS lookup for @p hostname and returns the result.
*
* This function uses the KIO/KHTML DNS cache to speed up the
* lookup. It also avoids doing a reverse lookup if the given
* host name is already an ip address.
* This function uses the KIO DNS cache to speed up the lookup.
* It also avoids doing a reverse lookup if the givem host name
* is already an IP address.
*
* \note All uri filter plugins that need to perform a hostname
* lookup should use this function.
@ -735,7 +735,7 @@ protected:
*
* @since 4.7
*/
QHostInfo resolveName (const QString& hostname, unsigned long timeout) const;
QHostInfo resolveName(const QString& hostname, unsigned long timeout) const;
private:
class KUriFilterPluginPrivate * const d;

View file

@ -34,7 +34,6 @@
#include <kurl.h>
#include <klocalizedstring.h>
#include <kio/hostinfo_p.h>
namespace
{
@ -168,11 +167,7 @@ namespace
// needless reverse lookup
QHostAddress address ( host );
if ( address.isNull() ) {
QHostInfo hostInfo = KIO::HostInfo::lookupCachedHostInfoFor(host);
if (hostInfo.hostName().isEmpty() || hostInfo.error() != QHostInfo::NoError) {
hostInfo = QHostInfo::fromName(host);
KIO::HostInfo::cacheLookup(hostInfo);
}
QHostInfo hostInfo = QHostInfo::fromName(host);
m_addressList = hostInfo.addresses();
} else {
m_addressList.clear();

View file

@ -221,6 +221,8 @@ QString UDevDevice::icon() const
case Solid::OpticalDisc::DiscType::BluRayRecordable:
case Solid::OpticalDisc::DiscType::BluRayRewritable:
return QLatin1String("media-optical-blu-ray");
default:
break;
}
// fallback for every other optical disc