[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/extragear/graphics/digikam/1.0-databaseext
From:       Holger Foerster <hamsi2k () freenet ! de>
Date:       2010-02-11 10:26:07
Message-ID: 1265883967.855492.21101.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1088617 by foerster:

Using database error handler also for normal errors.

 M  +38 -31    digikam/databaseerrorhandler.cpp  
 M  +1 -1      digikam/databaseerrorhandler.h  
 M  +9 -10     libs/database/databasecorebackend.cpp  
 M  +1 -1      libs/database/databasecorebackend.h  
 M  +1 -1      libs/database/databasecorebackend_p.h  


--- branches/extragear/graphics/digikam/1.0-databaseext/digikam/databaseerrorhandler.cpp \
#1088616:1088617 @@ -71,7 +71,7 @@
                  databaseHandler.close();
              }else
              {
-                 kDebug(50003) << "Error while opening the database. Error details \
[" << databaseHandler.lastError() << "]"; +                 kError(50003) << "Error \
while opening the database. Error details [" << databaseHandler.lastError() << "]";  \
sleep(2);  }
 
@@ -95,44 +95,51 @@
 
     }
 
-    void DatabaseGUIErrorHandler::connectionError(DatabaseErrorAnswer *answer){
-        // now we try to connect periodically to the database
-        DatabaseConnectionChecker connectionChecker(parameters);
+    void DatabaseGUIErrorHandler::databaseError(DatabaseErrorAnswer *answer,  const \
SqlQuery& query){ +        if (query.lastError().type() == QSqlError::ConnectionError \
|| query.lastError().number()==2006){ +            // now we try to connect \
periodically to the database +            DatabaseConnectionChecker \
connectionChecker(parameters);  
-        QWidget* parent = QWidget::find(0);
-        KProgressDialog *dialog = new KProgressDialog(parent);
-        dialog->progressBar()->setMinimum(0);
-        dialog->progressBar()->setMaximum(0);
-        dialog->setModal(true);
-        dialog->setLabelText(i18n("Error while opening the database.\nDigikam will \
                try to automatically reconnect to the database."));
-        connectionChecker.setDialog(dialog);
-        dialog->connect(&connectionChecker, SIGNAL(done()), SLOT(accept()));
-        connectionChecker.start();
+            QWidget* parent = QWidget::find(0);
+            KProgressDialog *dialog = new KProgressDialog(parent);
+            dialog->progressBar()->setMinimum(0);
+            dialog->progressBar()->setMaximum(0);
+            dialog->setModal(true);
+            dialog->setLabelText(i18n("Error while opening the database.\nDigikam \
will try to automatically reconnect to the database.")); +            \
connectionChecker.setDialog(dialog); +            dialog->connect(&connectionChecker, \
SIGNAL(done()), SLOT(accept())); +            connectionChecker.start();
 
 
-        // We use a QPointer because the dialog may get deleted
-        // during exec() if the parent of the dialog gets deleted.
-        // In that case the QPointer will reset to 0.
-        QPointer<KDialog> guardedDialog = dialog;
+            // We use a QPointer because the dialog may get deleted
+            // during exec() if the parent of the dialog gets deleted.
+            // In that case the QPointer will reset to 0.
+            QPointer<KDialog> guardedDialog = dialog;
 
-        guardedDialog->exec();
-        connectionChecker.stop=true;
+            guardedDialog->exec();
+            connectionChecker.stop=true;
 
-        // simple for loop to ensure, the connection thread is closed
-        connectionChecker.wait();
+            // simple for loop to ensure, the connection thread is closed
+            connectionChecker.wait();
 
-        if ( dialog->wasCancelled() )
+            if ( dialog->wasCancelled() )
+            {
+                answer->connectionErrorAbortQueries();
+            }else
+            {
+                answer->connectionErrorContinueQueries();
+            }
+
+            delete (KDialog *) guardedDialog;
+        }else
         {
+            QWidget* parent = QWidget::find(0);
+            // Handle all other database errors
+            QString message = i18n("<p><b>A Database error was occurred.</b></p>"
+                                   "Details:\n"
+                                   "%1", query.lastError().text());
+            KMessageBox::error(parent, message);
             answer->connectionErrorAbortQueries();
-        }else
-        {
-            answer->connectionErrorContinueQueries();
         }
-
-        delete (KDialog *) guardedDialog;
     }
-
-
-
-
 }  // namespace Digikam
--- branches/extragear/graphics/digikam/1.0-databaseext/digikam/databaseerrorhandler.h \
#1088616:1088617 @@ -69,7 +69,7 @@
     bool               refuseQueries;
 
 private Q_SLOTS:
-    virtual void connectionError(DatabaseErrorAnswer *answer);
+    virtual void databaseError(DatabaseErrorAnswer *answer,  const SqlQuery& query);
 
 };
 
--- branches/extragear/graphics/digikam/1.0-databaseext/libs/database/databasecorebackend.cpp \
#1088616:1088617 @@ -324,7 +324,7 @@
 }
 
 /// Returns true if the query shall be retried
-bool DatabaseCoreBackendPrivate::checkConnectionError()
+bool DatabaseCoreBackendPrivate::checkDatabaseError(const SqlQuery& query)
 {
     if (errorHandler!=0)
     {
@@ -332,12 +332,12 @@
         setQueryOperationFlag(DatabaseCoreBackend::Wait);
         if (isInUIThread())
         {
-            errorHandler->connectionError(this);
+            errorHandler->databaseError(this, query);
         }
         else
         {
                         bool ret = QMetaObject::invokeMethod(errorHandler, \
                "connectionError",
-                                                  Qt::QueuedConnection, \
Q_ARG(DatabaseErrorAnswer*, this)); +                                                 \
Qt::QueuedConnection, Q_ARG(DatabaseErrorAnswer*, this), Q_ARG(const SqlQuery, \
query));  
 //            bool ret = QMetaObject::invokeMethod(errorHandler, \
SLOT(connectionError(DatabaseErrorAnswer *)),  //                                     \
Qt::QueuedConnection, Q_ARG(DatabaseErrorAnswer*, this)); @@ -795,18 +795,17 @@
     Q_D(DatabaseCoreBackend);
 
     kDebug(50003) << "Detected error type [" << query.lastError().type() << "]";
-    if (query.lastError().type() == QSqlError::ConnectionError || \
query.lastError().number()==2006) +    if (d->isSQLiteLockError(query))
     {
-        if (d->checkConnectionError())
+        if (d->checkRetrySQLiteLockError(retries))
             return true;
+    }else
+    {
+        if (d->checkDatabaseError(query))
+            return true;
         else
             return false;
     }
-    else if (d->isSQLiteLockError(query))
-    {
-        if (d->checkRetrySQLiteLockError(retries))
-            return true;
-    }
     d->debugOutputFailedQuery(query);
     return false;
 }
--- branches/extragear/graphics/digikam/1.0-databaseext/libs/database/databasecorebackend.h \
#1088616:1088617 @@ -67,7 +67,7 @@
      *  It must then call either connectionErrorContinueQueries()
      *  or connectionErrorAbortQueries().
      */
-    virtual void connectionError(DatabaseErrorAnswer *answer) = 0;
+    virtual void databaseError(DatabaseErrorAnswer *answer, const SqlQuery &query) = \
0;  
 };
 
--- branches/extragear/graphics/digikam/1.0-databaseext/libs/database/databasecorebackend_p.h \
#1088616:1088617 @@ -64,7 +64,7 @@
     void debugOutputFailedQuery(const QSqlQuery &query);
 
     bool checkOperationStatus();
-    bool checkConnectionError();
+    bool checkDatabaseError(const SqlQuery& query);
     // called by DatabaseErrorHandler, implementing DatabaseErrorAnswer
     virtual void connectionErrorContinueQueries();
     virtual void connectionErrorAbortQueries();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic