From c9ab4595a61640c157f55c1d7908d8fc6bf2ec9e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 28 Feb 2011 15:58:52 +0100 Subject: 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 --- src/useragent/useragentinfo.cpp | 28 ++++++++++++++++++++-------- src/useragent/useragentinfo.h | 2 ++ 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; }; -- cgit v1.2.1