check xdxf file
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Fri, 3 Sep 2010 06:28:50 +0000 (08:28 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Fri, 3 Sep 2010 06:28:50 +0000 (08:28 +0200)
src/mdictionary/backbone/backbone.cpp
src/mdictionary/gui/DictManagerWidget.cpp
src/plugins/xdxf/xdxfplugin.cpp

index 8e13e16..2bff627 100644 (file)
@@ -249,13 +249,15 @@ void Backbone::addDictionary(CommonDictInterface *dict, bool active) {
 
 
 
- void Backbone::addInternalDictionary(CommonDictInterface* dict, bool active) {
-     dict->setHash(++_dictNum); // Hash must be uniqe in every session but not between
-     _dicts[dict] = active;
-     connect(dict, SIGNAL(settingsChanged()), this, SLOT(dictUpdated()));
-     connect(dict, SIGNAL(notify(Notify::NotifyType,QString)), this,
-             SIGNAL(notify(Notify::NotifyType,QString)));
- }
+void Backbone::addInternalDictionary(CommonDictInterface* dict, bool active) {
+    if(dict) {
+        dict->setHash(++_dictNum); // Hash must be uniqe in every session but not between
+        _dicts[dict] = active;
+        connect(dict, SIGNAL(settingsChanged()), this, SLOT(dictUpdated()));
+        connect(dict, SIGNAL(notify(Notify::NotifyType,QString)), this,
+            SIGNAL(notify(Notify::NotifyType,QString)));
+    }
+}
 
 
 
index 292e47c..4e60992 100644 (file)
@@ -182,8 +182,10 @@ void DictManagerWidget::addNewDictButtonClicked() {
 
        if(settings != NULL) {
            CommonDictInterface* newDict = selectedPlugin->getNew(settings);
-           delete settings;
-           Q_EMIT addDictionary(newDict);
+           if(newDict) {
+               delete settings;
+               Q_EMIT addDictionary(newDict);
+           }
        }
    }
    refreshDictsList();
index 9335759..884ae7d 100644 (file)
@@ -314,7 +314,7 @@ CommonDictInterface* XdxfPlugin::getNew(const Settings *settings) const {
         return plugin;
     else {
         delete plugin;
-        return new XdxfPlugin();
+        return 0;
     }
 }
 
@@ -357,12 +357,17 @@ bool XdxfPlugin::setSettings(const Settings *settings) {
     if(settings) {
         bool isPathChange=false;
         QString oldPath = _settings->value("path");
+        Settings *oldSettings =  new Settings ;
+
         if(oldPath != settings->value("path")) {
             if(oldPath!="" && _settings->value("cache_path")!="")
                 clean();
             isPathChange=true;
         }
 
+        foreach(QString key, _settings->keys())
+            oldSettings->setValue(key, _settings->value(key));
+
         foreach(QString key, settings->keys()) {
            if(key != "generateCache")
                _settings->setValue(key, settings->value(key));
@@ -372,6 +377,8 @@ bool XdxfPlugin::setSettings(const Settings *settings) {
             Q_EMIT notify(Notify::Warning,
                 QString(tr("XDXF file is in wrong format")));
             qDebug()<<"Error: xdxf file is in wrong format";
+            delete _settings;
+            _settings=oldSettings;
             return false;
         }