SetupPage: Fix crash caused by uninitialized Account object.
authorKlaas Freitag <freitag@owncloud.com>
Thu, 10 Sep 2015 14:03:22 +0000 (16:03 +0200)
committerKlaas Freitag <freitag@owncloud.com>
Thu, 10 Sep 2015 14:03:22 +0000 (16:03 +0200)
Since the webdav path is read from account now, it needs to be
initialized first thing.

src/gui/wizard/owncloudsetuppage.cpp

index 616caa0075c41bf5d4082d981f9b7b91de22e29c..d3ea76b3213855f62860e927d06dd412946b8f01 100644 (file)
@@ -45,6 +45,7 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent)
     _progressIndi(new QProgressIndicator (this))
 {
     _ui.setupUi(this);
+    _ocWizard = qobject_cast<OwncloudWizard *>(parent);
 
     Theme *theme = Theme::instance();
     setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(theme->appNameGUI())));
@@ -66,7 +67,6 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent)
     connect(_ui.leUrl, SIGNAL(editingFinished()), SLOT(slotUrlEditFinished()));
 
     addCertDial = new AddCertificateDialog(this);
-    _ocWizard = qobject_cast<OwncloudWizard *>(parent);
     connect(_ocWizard,SIGNAL(needCertificate()),this,SLOT(slotAskSSLClientCertificate()));
 }
 
@@ -106,14 +106,16 @@ void OwncloudSetupPage::slotUrlChanged(const QString& url)
     if (url.endsWith("index.php")) {
         newUrl.chop(9);
     }
-    QString webDavPath = _ocWizard->account()->davPath();
-    if (url.endsWith(webDavPath)) {
-        newUrl.chop( webDavPath.length() );
-    }
-    if( webDavPath.endsWith(QLatin1Char('/')) ) {
-        webDavPath.chop(1); // cut off the slash
-        if( url.endsWith(webDavPath)) {
-            newUrl.chop(webDavPath.length());
+    if( _ocWizard && _ocWizard->account() ) {
+        QString webDavPath = _ocWizard->account()->davPath();
+        if (url.endsWith(webDavPath)) {
+            newUrl.chop( webDavPath.length() );
+        }
+        if( webDavPath.endsWith(QLatin1Char('/')) ) {
+            webDavPath.chop(1); // cut off the slash
+            if( url.endsWith(webDavPath)) {
+                newUrl.chop(webDavPath.length());
+            }
         }
     }
     if (newUrl != url) {