Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-17728

Working directory is not updated when adding a configuration

    XMLWordPrintable

Details

    Description

      When adding a new configuration / kit to a project, the working directory is not correctly set for the application. Instead, the working directory of QtCreator is used. This can cause issues like some resources failing to load (if they're not in a .qrc).

      A simple test case is to create a Qt widgets application, and edit the mainwindow.cpp contents to be:

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      #include <QDebug>
      #include <QDir>
      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
          qDebug() << "Current directory:" << QDir::currentPath();
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      

      The working directory will be reported as the directory from where the Qt creator was launched, instead of the one specified in the run configuration.

      A workaround is to go to the run settings, and then do a slight modification in the working directory (add a letter and then remove it, for example). At least sometimes the correct directory is retained when closing+reopening the project and/or Qt creator, but I'm not sure if this is always the case, or if there are other ways to cause this bug again (I'm using multiple Qt builds, but I feel like I need to do this workaround over and over again).

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            hunger Tobias Hunger
            fintux Jukka Alasalmi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes