~ps-jenkins/qtubuntu/latestsnapshot-0.52+13.10.20130812.3-0ubuntu1

« back to all changes in this revision

Viewing changes to src/modules/application/application_manager.cc

Respect Path= from .desktop files. Fixes: https://bugs.launchpad.net/bugs/1204596.

Approved by Sergio Schvezov, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
185
185
    { "Comment=", sizeof("Comment=") - 1, 1 << DesktopData::kCommentIndex },
186
186
    { "Icon=", sizeof("Icon=") - 1, 1 << DesktopData::kIconIndex },
187
187
    { "Exec=", sizeof("Exec=") - 1, 1 << DesktopData::kExecIndex },
 
188
    { "Path=", sizeof("Path=") - 1, 1 << DesktopData::kPathIndex },
188
189
    { "X-Ubuntu-StageHint=", sizeof("X-Ubuntu-StageHint=") - 1, 1 << DesktopData::kStageHintIndex }
189
190
  };
190
191
  const unsigned int kAllEntriesMask =
191
192
      (1 << DesktopData::kNameIndex) | (1 << DesktopData::kCommentIndex)
192
193
      | (1 << DesktopData::kIconIndex) | (1 << DesktopData::kExecIndex)
193
 
      | (1 << DesktopData::kStageHintIndex);
 
194
      | (1 << DesktopData::kPathIndex) | (1 << DesktopData::kStageHintIndex);
194
195
  const unsigned int kMandatoryEntriesMask =
195
196
      (1 << DesktopData::kNameIndex) | (1 << DesktopData::kIconIndex)
196
197
      | (1 << DesktopData::kExecIndex);
243
244
 
244
245
  // Check that the mandatory entries are set.
245
246
  if ((entryFlags & kMandatoryEntriesMask) == kMandatoryEntriesMask) {
246
 
    DLOG("loaded desktop file with name='%s', comment='%s', icon='%s', exec='%s', stagehint='%s'",
 
247
    DLOG("loaded desktop file with name='%s', comment='%s', icon='%s', exec='%s', path='%s', stagehint='%s'",
247
248
         entries_[DesktopData::kNameIndex].toLatin1().data(),
248
249
         entries_[DesktopData::kCommentIndex].toLatin1().data(),
249
250
         entries_[DesktopData::kIconIndex].toLatin1().data(),
250
251
         entries_[DesktopData::kExecIndex].toLatin1().data(),
 
252
         entries_[DesktopData::kPathIndex].toLatin1().data(),
251
253
         entries_[DesktopData::kStageHintIndex].toLatin1().data());
252
254
    return true;
253
255
  } else {
603
605
  // Start process.
604
606
  bool result;
605
607
  qint64 pid = 0;
606
 
  struct passwd* passwd = getpwuid(getuid());
607
 
  DLOG("current working directory: '%s'", passwd ? passwd->pw_dir : "/");
 
608
  QString path = "/";
 
609
  // respect Path from .desktop file
 
610
  if (desktopData->path() != "") {
 
611
    path = desktopData->path();
 
612
  } else {
 
613
    struct passwd* passwd = getpwuid(getuid());
 
614
    if (passwd)
 
615
      path = passwd->pw_dir;
 
616
  }
 
617
  DLOG("current working directory: '%s'", path.toLatin1().data());
608
618
  QByteArray envSetAppId = QString("APP_ID=%1").arg(appId).toLocal8Bit();
609
619
  putenv(envSetAppId.data()); // envSetAppId must be available and unmodified until the env var is unset
610
 
  result = QProcess::startDetached(exec, arguments, QString(passwd ? passwd->pw_dir : "/"), &pid);
 
620
  result = QProcess::startDetached(exec, arguments, path, &pid);
611
621
  QByteArray envClearAppId = QString("APP_ID").toLocal8Bit();
612
622
  putenv(envClearAppId.data()); // now it's safe to deallocate envSetAppId.
613
623
  DLOG_IF(result == false, "process failed to start");