Web lists-archives.com

[PATCH 2/2] Fix saving host preferences




From: Arno <arno@xxxxxxxxxxxxx>

Well, this one was fun. Took me a while to figure out that saving
the preferences for a host also destroys the view...

When passing an URL via command line, somehow saveHostPrefs() is
being called, destroying the just created view, leaving the
baffled user with only a new connection view.

Also, I don't understand why the view has to be destroyed if
the user has chosen not to see the prefereces dialog for the host.
Just show it or not, depending on the settings.
---
 main.cpp       | 1 +
 mainwindow.cpp | 6 +-----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/main.cpp b/main.cpp
index e5374c4..02d24de 100644
--- a/main.cpp
+++ b/main.cpp
@@ -123,6 +123,7 @@ int main(int argc, char **argv)
                 QString arg = args.at(i);
 
                 if(arg.startsWith(QStringLiteral("rdp://")) || arg.startsWith(QStringLiteral("vnc://")) || arg.startsWith(QStringLiteral("nx://"))){
+                    qCDebug(KRDC) << "Using url:" << arg;
                     url = QUrl(arg);
                 }else{
                     qCDebug(KRDC) << "skipped url:" << arg << "because it's invalid";
diff --git a/mainwindow.cpp b/mainwindow.cpp
index dd1d8a0..20a7b47 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -299,10 +299,7 @@ void MainWindow::newConnection(const QUrl &newUrl, bool switchFullscreenWhenConn
 
     // Configure the view
     HostPreferences* prefs = view->hostPreferences();
-    if (! prefs->showDialogIfNeeded(this)) {
-        delete view;
-        return;
-    }
+    prefs->showDialogIfNeeded(this);
 
     view->showDotCursor(prefs->showLocalCursor() ? RemoteView::CursorOn : RemoteView::CursorOff);
     view->setViewOnly(prefs->viewOnly());
@@ -989,7 +986,6 @@ void MainWindow::saveHostPrefs()
 {
     foreach (RemoteView *view, m_remoteViewMap.values()) {
         saveHostPrefs(view);
-        view->startQuitting();
     }
 }
 
-- 
2.8.2