[krusader] krusader/GUI: GUI: fixed embedded terminal killed if chdir input is send too early

Alexander Bikadorov null at kde.org
Sun Aug 20 16:34:01 UTC 2017


Git commit b7980a8025e9f96b77ec625478cccfc908b566cc by Alexander Bikadorov.
Committed on 20/08/2017 at 16:31.
Pushed by abikadorov into branch 'master'.

GUI: fixed embedded terminal killed if chdir input is send too early

FIXED: [ 383372 ] Toggle Fullscreen Embedded Terminal bug
BUG: 383372

M  +12   -6    krusader/GUI/terminaldock.cpp
M  +1    -0    krusader/GUI/terminaldock.h

https://commits.kde.org/krusader/b7980a8025e9f96b77ec625478cccfc908b566cc

diff --git a/krusader/GUI/terminaldock.cpp b/krusader/GUI/terminaldock.cpp
index fa565b1c..4c44361b 100644
--- a/krusader/GUI/terminaldock.cpp
+++ b/krusader/GUI/terminaldock.cpp
@@ -19,10 +19,11 @@
 #include "terminaldock.h"
 
 // QtCore
-#include <QEvent>
+#include <QDebug>
 #include <QDir>
-#include <QString>
+#include <QEvent>
 #include <QObject>
+#include <QString>
 #include <QUrl>
 // QtGui
 #include <QKeyEvent>
@@ -56,7 +57,7 @@
  * A widget containing the konsolepart for the Embedded terminal emulator
  */
 TerminalDock::TerminalDock(QWidget* parent, KrMainWindow *mainWindow) : QWidget(parent),
-    _mainWindow(mainWindow), konsole_part(0), t(0), initialised(false)
+    _mainWindow(mainWindow), konsole_part(0), t(0), initialised(false), firstInput(true)
 {
     terminal_hbox = new QHBoxLayout(this);
 }
@@ -79,8 +80,8 @@ bool TerminalDock::initialise()
             if (konsole_part) { //loaded successfully
                 terminal_hbox->addWidget(konsole_part->widget());
                 setFocusProxy(konsole_part->widget());
-                connect(konsole_part, SIGNAL(destroyed()),
-                        this, SLOT(killTerminalEmulator()));
+                connect(konsole_part, &KParts::ReadOnlyPart::destroyed, this,
+                        &TerminalDock::killTerminalEmulator);
                 // must filter app events, because some of them are processed
                 // by child widgets of konsole_part->widget()
                 // and would not be received on konsole_part->widget()
@@ -91,6 +92,7 @@ bool TerminalDock::initialise()
                     t->showShellInDir(lastPath);
                 }
                 initialised = true;
+                firstInput = true;
             } else
                 KMessageBox::error(0, i18n("<b>Cannot create embedded terminal.</b><br/>"
                                            "The reported error was: %1", error));
@@ -114,6 +116,8 @@ bool TerminalDock::initialise()
 
 void TerminalDock::killTerminalEmulator()
 {
+    qDebug() << "killed";
+
     initialised = false;
     konsole_part = NULL;
     t = NULL;
@@ -131,10 +135,12 @@ void TerminalDock::sendInput(const QString& input, bool clearCommand)
         // and command is appended to current input (e.g. "rm -rf x " concatenated with 'cd /usr');
         // code "borrowed" from Dolphin, Copyright (C) 2007-2010 by Peter Penz <peter.penz19 at gmail.com>
         const int processId = t->terminalProcessId();
-        if (processId > 0) {
+        // workaround (firstInput): kill is send to terminal if shell is not initialized yet
+        if (processId > 0 && !firstInput) {
             kill(processId, SIGINT);
         }
     }
+    firstInput = false;
 
     t->sendInput(input);
 }
diff --git a/krusader/GUI/terminaldock.h b/krusader/GUI/terminaldock.h
index 50442d1c..8eed69c0 100644
--- a/krusader/GUI/terminaldock.h
+++ b/krusader/GUI/terminaldock.h
@@ -65,6 +65,7 @@ private:
     KParts::ReadOnlyPart* konsole_part;     // the actual part pointer
     TerminalInterface* t;                   // TerminalInterface of the konsole part
     bool initialised;
+    bool firstInput;
     bool applyShortcuts(QKeyEvent * ke);
 };
 



More information about the kde-doc-english mailing list