Merge branch 'cache' of ssh://drop.maemo.org/git/mdictionary into cache
[mdictionary] / trunk / src / plugins / xdxf / src / xdxfplugin.cpp
index eee24d0..fee5602 100644 (file)
@@ -102,6 +102,7 @@ QList<Translation*> XdxfPlugin::searchWordListCache(QString word, int limit) {
         while(cur.next())
             translations.insert(new TranslationXdxf(cur.value(0).toString(),
                                                     _infoNote, this));
+        db.close();
         return translations.toList();
 }
 
@@ -179,6 +180,7 @@ QString XdxfPlugin::searchCache(QString key) {
     cur.exec();
     if(cur.next())
         result = cur.value(0).toString();
+    db.close();
     return result;
 
 }
@@ -262,6 +264,7 @@ CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
 
         plugin->db_name = plugin->_settings->value("type")
                + plugin->_settings->value("path");
+        if(!plugin->db.connectionName().isEmpty())
         plugin->db = QSqlDatabase::addDatabase("QSQLITE", plugin->db_name);
 
         if(settings->value("cached").isEmpty() &&
@@ -484,10 +487,14 @@ bool XdxfPlugin::makeCache(QString dir) {
     cachingDialog->setVisible(false);
 
     if(!cur.next() || countWords() != cur.value(0).toInt())
+    {
+        db.close();
         return false;
+    }
     _settings->setValue("cache_path", cachePathN);
     _settings->setValue("cached", "true");
 
+    db.close();
     return true;
 }