Fixed a mysterious login error that occured on some machines
[situare] / src / facebookservice / facebookauthentication.cpp
index 8ca5ea5..8dbaf02 100644 (file)
@@ -38,7 +38,8 @@ FacebookAuthentication::FacebookAuthentication(QWidget *parent)
     m_email(),
     m_loginAttempts(0),
     m_password(),
-    m_refresh(0)
+    m_refresh(0),
+    m_webView(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -54,6 +55,9 @@ FacebookAuthentication::~FacebookAuthentication()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    if(m_webView)
+        delete m_webView;
+
     delete m_mainlayout;
 }
 
@@ -67,10 +71,11 @@ void FacebookAuthentication::loginDialogDone(const QString &email, const QString
 
 void FacebookAuthentication::start()
 {
-    qDebug() << __PRETTY_FUNCTION__;    
-    if (!verifyCredentials(m_loginCredentials)){
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (!verifyCredentials(m_loginCredentials)) {
 
-        m_webView = new QWebView(this);
+        m_webView = new QWebView;
         m_loginDialog = new LoginDialog(this);
 
         connect(m_webView, SIGNAL(urlChanged(const QUrl &)),
@@ -82,7 +87,7 @@ void FacebookAuthentication::start()
                 this, SLOT(loginDialogDone(QString,QString)));
 
         if(m_loginDialog->exec() != QDialog::Accepted) {
-            // if login dialog was canceled we need to stop processing webview            
+            // if login dialog was canceled we need to stop processing webview
             // stop and disconnect m_webView;
             m_webView->stop();
             disconnect(m_webView, SIGNAL(loadFinished(bool)),
@@ -105,8 +110,8 @@ void FacebookAuthentication::start()
         toggleProgressIndicator(true);
         m_refresh = true;
         setCentralWidget(m_webView);
-        this->show();
         m_webView->hide();
+        this->show();
     }
     else
         emit credentialsReady(m_loginCredentials);