[X2Go-Commits] [x2goclient] 19/31: src/pulsemanager.cpp: check server_binary_ before using it and jump over code that assumes the PA server binary to be available.

git-admin at x2go.org git-admin at x2go.org
Sun Mar 5 23:22:24 CET 2017


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goclient.

commit 9609888276207da5cbdf62df29aeaf7b9cd19753
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Sat Feb 25 05:03:45 2017 +0100

    src/pulsemanager.cpp: check server_binary_ before using it and jump over code that assumes the PA server binary to be available.
---
 debian/changelog     |  2 ++
 src/pulsemanager.cpp | 52 +++++++++++++++++++++++++++++-----------------------
 2 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 321e641..2685967 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -108,6 +108,8 @@ x2goclient (4.1.0.1-0x2go1) UNRELEASED; urgency=medium
       is unknown. Or just continue without PA support as such.
     - src/pulsemanager.{cpp,h}: add show_startup_warning () for both PA server
       and (debug) startup sound playback.
+    - src/pulsemanager.cpp: check server_binary_ before using it and jump over
+      code that assumes the PA server binary to be available.
 
   [ Oleksandr Shneyder ]
   * New upstream version (4.1.0.1):
diff --git a/src/pulsemanager.cpp b/src/pulsemanager.cpp
index 67d78b4..29bf439 100644
--- a/src/pulsemanager.cpp
+++ b/src/pulsemanager.cpp
@@ -135,11 +135,13 @@ PulseManager::PulseManager () : app_dir_ (QApplication::applicationDirPath ()),
     abort ();
   }
 
-  QFileInfo tmp_file_info = QFileInfo (server_binary_);
-  server_working_dir_ = tmp_file_info.canonicalPath ();
+  if (!(server_binary_.isEmpty ())) {
+    QFileInfo tmp_file_info = QFileInfo (server_binary_);
+    server_working_dir_ = tmp_file_info.canonicalPath ();
 
-  x2goDebug << "Found PA binary as " << server_binary_;
-  x2goDebug << "Corresponding working dir: " << server_working_dir_;
+    x2goDebug << "Found PA binary as " << server_binary_;
+    x2goDebug << "Corresponding working dir: " << server_working_dir_;
+  }
 
 #elif defined (Q_OS_WIN)
   server_working_dir_ = QString (app_dir_ + "/pulse/");
@@ -182,7 +184,9 @@ PulseManager::PulseManager () : app_dir_ (QApplication::applicationDirPath ()),
   buf = ptr = NULL;
 #endif // defined (Q_OS_DARWIN)
 
-  fetch_pulseaudio_version ();
+  if (!(server_binary_.isEmpty ())) {
+    fetch_pulseaudio_version ();
+  }
 }
 
 PulseManager::~PulseManager () {
@@ -223,35 +227,37 @@ void PulseManager::start_generic () {
   pulse_server_->setProcessEnvironment (env_);
   pulse_server_->setWorkingDirectory (server_working_dir_);
 
-  pulse_server_->start (server_binary_, server_args_);
+  if (!(server_binary_.isEmpty ())) {
+    pulse_server_->start (server_binary_, server_args_);
 
-  /*
-   * We may wait here, because PulseManager runs in a separate thread.
-   * Otherwise, we'd better use signals and slots to not block the main thread.
-   */
-  if (pulse_server_->waitForStarted (-1)) {
-    x2goDebug << "pulse started with arguments " << server_args_ << "- waiting for it to finish...";
-    state_ = QProcess::Running;
+    /*
+     * We may wait here, because PulseManager runs in a separate thread.
+     * Otherwise, we'd better use signals and slots to not block the main thread.
+     */
+    if (pulse_server_->waitForStarted (-1)) {
+      x2goDebug << "pulse started with arguments " << server_args_ << "- waiting for it to finish...";
+      state_ = QProcess::Running;
 
-    connect (pulse_server_, SIGNAL (finished (int)),
-             this,          SLOT (slot_on_pulse_finished (int)));
+      connect (pulse_server_, SIGNAL (finished (int)),
+               this,          SLOT (slot_on_pulse_finished (int)));
 
-    env_.insert ("PULSE_SERVER", "127.0.0.1:" + QString::number (pulse_port_));
+      env_.insert ("PULSE_SERVER", "127.0.0.1:" + QString::number (pulse_port_));
 
 
-    QString clean_pulse_dir = pulse_dir_.absolutePath ();
+      QString clean_pulse_dir = pulse_dir_.absolutePath ();
 
 #ifdef Q_OS_WIN
-    clean_pulse_dir = wapiShortFileName (clean_pulse_dir);
+      clean_pulse_dir = wapiShortFileName (clean_pulse_dir);
 #endif /* defined (Q_OS_WIN) */
 
-    QString tmp_auth_cookie = QDir::toNativeSeparators (clean_pulse_dir + "/.pulse-cookie");
+      QString tmp_auth_cookie = QDir::toNativeSeparators (clean_pulse_dir + "/.pulse-cookie");
 
-    env_.insert ("PULSE_COOKIE", tmp_auth_cookie);
+      env_.insert ("PULSE_COOKIE", tmp_auth_cookie);
 
-    if (debug_) {
-      // Give PA a little time to come up.
-      QTimer::singleShot (3000, this, SLOT (slot_play_startup_sound ()));
+      if (debug_) {
+        // Give PA a little time to come up.
+        QTimer::singleShot (3000, this, SLOT (slot_play_startup_sound ()));
+      }
     }
   }
   else {

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list