Hi,

I just enabled "wolfram" searchengine and got a segfault, since the 
corresponding desktop file for this service is not installed.

I stepped through the code in this section a while and couldn't find a better 
solution to handle the situation where "SearchEngine::defaultEngine()" simply 
cannot return a valid SearchEngine pointer. So I attached a patch, that 
defaults again back to the hardcoded default engine (atm its google...)

Hopefully someone of you have a nicer solution in mind ;-)

Regards,
Johannes

PS: Personally I like the sending-patch-to-mailinglist approach, only the 
commit count is poor then ;-)
diff --git a/src/searchengine.cpp b/src/searchengine.cpp
index 0d2c6ae..1f66677 100644
--- a/src/searchengine.cpp
+++ b/src/searchengine.cpp
@@ -100,6 +100,8 @@ KService::Ptr SearchEngine::fromString(QString text)
 
 QString SearchEngine::buildQuery(KService::Ptr engine, QString text)
 {
+    if (!engine) return "";
+
     QString query = engine->property("Query").toString();
     query = query.replace("\...@}", KUrl::toPercentEncoding(text));
     return query;
@@ -141,6 +143,7 @@ KService::Ptr SearchEngine::defaultEngine()
 {
     int n = ReKonfig::searchEngine();
     QString engine;
+    KService::Ptr service;
     switch (n)
     {
     case 0:
@@ -163,5 +166,8 @@ KService::Ptr SearchEngine::defaultEngine()
         break;
     }
 
-    return KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine));
+    service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine));
+
+    if (service) return service;
+    else return KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg("google"));
 }
_______________________________________________
rekonq mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/rekonq

Reply via email to