diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp
index 014bf49dfc555b73c35ab46a2034623f4ee11b07..c3cb89506dd50f86f22a391ef005cf412fd0258d 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp
@@ -83,7 +83,7 @@ RunControl *MaemoDebugSupport::createDebugRunControl(MaemoRunConfiguration *runC
             params.executable = runConfig->remoteExecutableFilePath();
             params.debuggerCommand
                 = MaemoGlobal::remoteCommandPrefix(runConfig->remoteExecutableFilePath())
-                    + environment(debuggingType, runConfig->userEnvironmentChanges())
+                    + MaemoGlobal::remoteEnvironment(runConfig->userEnvironmentChanges())
                     + QLatin1String(" /usr/bin/gdb");
             params.connParams = devConf.server;
             params.localMountDir = runConfig->localDirToMountForRemoteGdb();
@@ -125,6 +125,7 @@ MaemoDebugSupport::MaemoDebugSupport(MaemoRunConfiguration *runConfig,
       m_runner(new MaemoSshRunner(this, runConfig, true)),
       m_debuggingType(runConfig->debuggingType()),
       m_dumperLib(runConfig->dumperLib()),
+      m_userEnvChanges(runConfig->userEnvironmentChanges()),
       m_state(Inactive), m_gdbServerPort(-1), m_qmlPort(-1),
       m_useGdb(useGdb)
 {
@@ -278,9 +279,12 @@ void MaemoDebugSupport::startDebugging()
             SLOT(handleRemoteOutput(QByteArray)));
         const QString &remoteExe = m_runner->remoteExecutable();
         const QString cmdPrefix = MaemoGlobal::remoteCommandPrefix(remoteExe);
-        const QString env
-            = environment(m_debuggingType, m_runner->userEnvChanges());
-        const QString args = m_runner->arguments();
+        const QString env = MaemoGlobal::remoteEnvironment(m_userEnvChanges);
+        QString args = m_runner->arguments();
+        if (m_debuggingType != MaemoRunConfiguration::DebugCppOnly) {
+            args += QString(QLatin1String(" -qmljsdebugger=port:%1,block"))
+                .arg(m_qmlPort);
+        }
         const QString remoteCommandLine
             = m_debuggingType == MaemoRunConfiguration::DebugQmlOnly
                 ? QString::fromLocal8Bit("%1 %2 %3 %4").arg(cmdPrefix).arg(env)
@@ -352,17 +356,6 @@ void MaemoDebugSupport::setState(State newState)
     }
 }
 
-QString MaemoDebugSupport::environment(MaemoRunConfiguration::DebuggingType debuggingType,
-    const QList<Utils::EnvironmentItem> &userEnvChanges)
-{
-    // FIXME: this must use command line argument instead: -qmljsdebugger=port:1234.
-    if (debuggingType != MaemoRunConfiguration::DebugCppOnly) {
-//        env << Utils::EnvironmentItem(QLatin1String(Debugger::Constants::E_QML_DEBUG_SERVER_PORT),
-//            QString::number(qmlServerPort(rc)));
-    }
-    return MaemoGlobal::remoteEnvironment(userEnvChanges);
-}
-
 QString MaemoDebugSupport::uploadDir(const MaemoDeviceConfig &devConf)
 {
     return MaemoGlobal::homeDirOnDevice(devConf.server.uname);
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.h b/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.h
index 4e72040027e13c794f4463e7e814c740bf681d6b..9e0a85e3333de4b9b4ff16a299e1633797bad90a 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.h
@@ -88,9 +88,6 @@ private:
         DumpersUploaded, StartingRemoteProcess, Debugging
     };
 
-    static QString environment(MaemoRunConfiguration::DebuggingType debuggingType,
-        const QList<Utils::EnvironmentItem> &userEnvChanges);
-
     void handleAdapterSetupFailed(const QString &error);
     void handleAdapterSetupDone();
     void startDebugging();
@@ -104,6 +101,7 @@ private:
     MaemoSshRunner * const m_runner;
     const MaemoRunConfiguration::DebuggingType m_debuggingType;
     const QString m_dumperLib;
+    const QList<Utils::EnvironmentItem> m_userEnvChanges;
 
     QSharedPointer<Core::SftpChannel> m_uploader;
     Core::SftpJobId m_uploadJob;