summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-02-28 15:58:52 +0100
committerAndrea Diamantini <adjam7@gmail.com>2011-02-28 15:58:52 +0100
commitc9ab4595a61640c157f55c1d7908d8fc6bf2ec9e (patch)
treefd086ff8063f32eb2b215b2a664880b4ff1fe529 /src
parentUpdated RELEASE_HOWTO (diff)
downloadrekonq-c9ab4595a61640c157f55c1d7908d8fc6bf2ec9e.tar.xz
Prevents rekonq from crash if an UA service cannot be found.
This fix needs IMHO an extra informational string that will be postponed to after 0.7 stable release. BUG:266997
Diffstat (limited to 'src')
-rw-r--r--src/useragent/useragentinfo.cpp28
-rw-r--r--src/useragent/useragentinfo.h2
2 files changed, 22 insertions, 8 deletions
diff --git a/src/useragent/useragentinfo.cpp b/src/useragent/useragentinfo.cpp
index d6b286b6..67390e94 100644
--- a/src/useragent/useragentinfo.cpp
+++ b/src/useragent/useragentinfo.cpp
@@ -61,9 +61,9 @@ UserAgentInfo::UserAgentInfo()
QString UserAgentInfo::userAgentString(int i)
{
- if (i < 0)
+ if (i < 0 || !providerExists(i))
{
- kDebug() << "oh oh... negative index on the user agent choice!";
+ kDebug() << "oh oh... wrong index on the user agent choice! INDEX = " << i;
return QL1S("Default");
}
@@ -98,9 +98,9 @@ QString UserAgentInfo::userAgentString(int i)
QString UserAgentInfo::userAgentName(int i)
{
- if (i < 0)
+ if (i < 0 || !providerExists(i))
{
- kDebug() << "oh oh... negative index on the user agent choice!";
+ kDebug() << "oh oh... wrong index on the user agent choice! INDEX = " << i;
return QL1S("Default");
}
@@ -110,9 +110,9 @@ QString UserAgentInfo::userAgentName(int i)
QString UserAgentInfo::userAgentVersion(int i)
{
- if (i < 0)
+ if (i < 0 || !providerExists(i))
{
- kDebug() << "oh oh... negative index on the user agent choice!";
+ kDebug() << "oh oh... wrong index on the user agent choice! INDEX = " << i;
return QL1S("Default");
}
@@ -122,9 +122,9 @@ QString UserAgentInfo::userAgentVersion(int i)
QString UserAgentInfo::userAgentDescription(int i)
{
- if (i < 0)
+ if (i < 0 || !providerExists(i))
{
- kDebug() << "oh oh... negative index on the user agent choice!";
+ kDebug() << "oh oh... wrong index on the user agent choice! INDEX = " << i;
return QL1S("Default");
}
@@ -186,3 +186,15 @@ int UserAgentInfo::uaIndexForHost(const QString &host)
}
return -1;
}
+
+
+bool UserAgentInfo::providerExists(int i)
+{
+ KService::Ptr s = m_providers.at(i);
+ if(s.isNull())
+ {
+ //FIXME Add me when string freeze has been reopened: KMessageBox::error(...)
+ return false;
+ }
+ return true;
+}
diff --git a/src/useragent/useragentinfo.h b/src/useragent/useragentinfo.h
index 68af50ab..f95c696c 100644
--- a/src/useragent/useragentinfo.h
+++ b/src/useragent/useragentinfo.h
@@ -71,6 +71,8 @@ private:
QString userAgentVersion(int);
QString userAgentDescription(int);
+ bool providerExists(int);
+
private:
KService::List m_providers;
};