forked from qt-creator/qt-creator
Fix parsing of filename with position when -client is used
Instead of transforming to absolute paths in the client, pass the working directory and leave it to the target. Change-Id: I4f8724c8857e89a7ee77116c78cf8b25c56795fa Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
facc89fafd
commit
17f2af5082
@@ -63,7 +63,9 @@ public:
|
|||||||
virtual void extensionsInitialized() = 0;
|
virtual void extensionsInitialized() = 0;
|
||||||
virtual bool delayedInitialize() { return false; }
|
virtual bool delayedInitialize() { return false; }
|
||||||
virtual ShutdownFlag aboutToShutdown() { return SynchronousShutdown; }
|
virtual ShutdownFlag aboutToShutdown() { return SynchronousShutdown; }
|
||||||
virtual QObject *remoteCommand(const QStringList & /* options */, const QStringList & /* arguments */) { return 0; }
|
virtual QObject *remoteCommand(const QStringList & /* options */,
|
||||||
|
const QString & /* workingDirectory */,
|
||||||
|
const QStringList & /* arguments */) { return 0; }
|
||||||
virtual QList<QObject *> createTestObjects() const;
|
virtual QList<QObject *> createTestObjects() const;
|
||||||
|
|
||||||
PluginSpec *pluginSpec() const;
|
PluginSpec *pluginSpec() const;
|
||||||
|
@@ -505,6 +505,7 @@ QHash<QString, PluginCollection *> PluginManager::pluginCollections()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char argumentKeywordC[] = ":arguments";
|
static const char argumentKeywordC[] = ":arguments";
|
||||||
|
static const char pwdKeywordC[] = ":pwd";
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Serializes plugin options and arguments for sending in a single string
|
Serializes plugin options and arguments for sending in a single string
|
||||||
@@ -528,20 +529,15 @@ QString PluginManager::serializedArguments()
|
|||||||
rc += ps->arguments().join(separator);
|
rc += ps->arguments().join(separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!rc.isEmpty())
|
||||||
|
rc += separator;
|
||||||
|
rc += QLatin1String(pwdKeywordC) + separator + QDir::currentPath();
|
||||||
if (!d->arguments.isEmpty()) {
|
if (!d->arguments.isEmpty()) {
|
||||||
if (!rc.isEmpty())
|
if (!rc.isEmpty())
|
||||||
rc += separator;
|
rc += separator;
|
||||||
rc += QLatin1String(argumentKeywordC);
|
rc += QLatin1String(argumentKeywordC);
|
||||||
// If the argument appears to be a file, make it absolute
|
foreach (const QString &argument, d->arguments)
|
||||||
// when sending to another instance.
|
rc += separator + argument;
|
||||||
foreach (const QString &argument, d->arguments) {
|
|
||||||
rc += separator;
|
|
||||||
const QFileInfo fi(argument);
|
|
||||||
if (fi.exists() && fi.isRelative())
|
|
||||||
rc += fi.absoluteFilePath();
|
|
||||||
else
|
|
||||||
rc += argument;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -577,11 +573,14 @@ void PluginManager::remoteArguments(const QString &serializedArgument, QObject *
|
|||||||
if (serializedArgument.isEmpty())
|
if (serializedArgument.isEmpty())
|
||||||
return;
|
return;
|
||||||
QStringList serializedArguments = serializedArgument.split(QLatin1Char('|'));
|
QStringList serializedArguments = serializedArgument.split(QLatin1Char('|'));
|
||||||
|
const QStringList pwdValue = subList(serializedArguments, QLatin1String(pwdKeywordC));
|
||||||
|
const QString workingDirectory = pwdValue.isEmpty() ? QString() : pwdValue.first();
|
||||||
const QStringList arguments = subList(serializedArguments, QLatin1String(argumentKeywordC));
|
const QStringList arguments = subList(serializedArguments, QLatin1String(argumentKeywordC));
|
||||||
foreach (const PluginSpec *ps, plugins()) {
|
foreach (const PluginSpec *ps, plugins()) {
|
||||||
if (ps->state() == PluginSpec::Running) {
|
if (ps->state() == PluginSpec::Running) {
|
||||||
const QStringList pluginOptions = subList(serializedArguments, QLatin1Char(':') + ps->name());
|
const QStringList pluginOptions = subList(serializedArguments, QLatin1Char(':') + ps->name());
|
||||||
QObject *socketParent = ps->plugin()->remoteCommand(pluginOptions, arguments);
|
QObject *socketParent = ps->plugin()->remoteCommand(pluginOptions, workingDirectory,
|
||||||
|
arguments);
|
||||||
if (socketParent && socket) {
|
if (socketParent && socket) {
|
||||||
socket->setParent(socketParent);
|
socket->setParent(socketParent);
|
||||||
socket = 0;
|
socket = 0;
|
||||||
|
@@ -226,17 +226,20 @@ bool CorePlugin::delayedInitialize()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject *CorePlugin::remoteCommand(const QStringList & /* options */, const QStringList &args)
|
QObject *CorePlugin::remoteCommand(const QStringList & /* options */,
|
||||||
|
const QString &workingDirectory,
|
||||||
|
const QStringList &args)
|
||||||
{
|
{
|
||||||
IDocument *res = m_mainWindow->openFiles(
|
IDocument *res = m_mainWindow->openFiles(
|
||||||
args, ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineNumbers));
|
args, ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineNumbers),
|
||||||
|
workingDirectory);
|
||||||
m_mainWindow->raiseWindow();
|
m_mainWindow->raiseWindow();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlugin::fileOpenRequest(const QString &f)
|
void CorePlugin::fileOpenRequest(const QString &f)
|
||||||
{
|
{
|
||||||
remoteCommand(QStringList(), QStringList(f));
|
remoteCommand(QStringList(), QString(), QStringList(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag CorePlugin::aboutToShutdown()
|
ExtensionSystem::IPlugin::ShutdownFlag CorePlugin::aboutToShutdown()
|
||||||
|
@@ -59,7 +59,9 @@ public:
|
|||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
bool delayedInitialize();
|
bool delayedInitialize();
|
||||||
ShutdownFlag aboutToShutdown();
|
ShutdownFlag aboutToShutdown();
|
||||||
QObject *remoteCommand(const QStringList & /* options */, const QStringList &args);
|
QObject *remoteCommand(const QStringList & /* options */,
|
||||||
|
const QString &workingDirectory,
|
||||||
|
const QStringList &args);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void fileOpenRequest(const QString&);
|
void fileOpenRequest(const QString&);
|
||||||
|
@@ -761,18 +761,24 @@ static IDocumentFactory *findDocumentFactory(const QList<IDocumentFactory*> &fil
|
|||||||
* \a flags can be used to stop on first failure, indicate that a file name
|
* \a flags can be used to stop on first failure, indicate that a file name
|
||||||
* might include line numbers and/or switch mode to edit mode.
|
* might include line numbers and/or switch mode to edit mode.
|
||||||
*
|
*
|
||||||
|
* \a workingDirectory is used when files are opened by a remote client, since
|
||||||
|
* the file names are relative to the client working directory.
|
||||||
|
*
|
||||||
* \returns the first opened document. Required to support the -block flag
|
* \returns the first opened document. Required to support the -block flag
|
||||||
* for client mode.
|
* for client mode.
|
||||||
*
|
*
|
||||||
* \sa IPlugin::remoteArguments()
|
* \sa IPlugin::remoteArguments()
|
||||||
*/
|
*/
|
||||||
IDocument *MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags)
|
IDocument *MainWindow::openFiles(const QStringList &fileNames,
|
||||||
|
ICore::OpenFilesFlags flags,
|
||||||
|
const QString &workingDirectory)
|
||||||
{
|
{
|
||||||
QList<IDocumentFactory*> documentFactories = PluginManager::getObjects<IDocumentFactory>();
|
QList<IDocumentFactory*> documentFactories = PluginManager::getObjects<IDocumentFactory>();
|
||||||
IDocument *res = 0;
|
IDocument *res = 0;
|
||||||
|
|
||||||
foreach (const QString &fileName, fileNames) {
|
foreach (const QString &fileName, fileNames) {
|
||||||
const QFileInfo fi(fileName);
|
const QDir workingDir(workingDirectory.isEmpty() ? QDir::currentPath() : workingDirectory);
|
||||||
|
const QFileInfo fi(workingDir, fileName);
|
||||||
const QString absoluteFilePath = fi.absoluteFilePath();
|
const QString absoluteFilePath = fi.absoluteFilePath();
|
||||||
if (IDocumentFactory *documentFactory = findDocumentFactory(documentFactories, fi)) {
|
if (IDocumentFactory *documentFactory = findDocumentFactory(documentFactories, fi)) {
|
||||||
IDocument *document = documentFactory->open(absoluteFilePath);
|
IDocument *document = documentFactory->open(absoluteFilePath);
|
||||||
|
@@ -94,7 +94,9 @@ public:
|
|||||||
void addContextObject(IContext *context);
|
void addContextObject(IContext *context);
|
||||||
void removeContextObject(IContext *context);
|
void removeContextObject(IContext *context);
|
||||||
|
|
||||||
IDocument *openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags);
|
IDocument *openFiles(const QStringList &fileNames,
|
||||||
|
ICore::OpenFilesFlags flags,
|
||||||
|
const QString &workingDirectory = QString());
|
||||||
|
|
||||||
inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; }
|
inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; }
|
||||||
virtual QPrinter *printer() const;
|
virtual QPrinter *printer() const;
|
||||||
|
@@ -737,7 +737,7 @@ public:
|
|||||||
|
|
||||||
void runControlStarted(DebuggerEngine *engine);
|
void runControlStarted(DebuggerEngine *engine);
|
||||||
void runControlFinished(DebuggerEngine *engine);
|
void runControlFinished(DebuggerEngine *engine);
|
||||||
void remoteCommand(const QStringList &options, const QStringList &);
|
void remoteCommand(const QStringList &options);
|
||||||
|
|
||||||
void displayDebugger(DebuggerEngine *engine, bool updateEngine = true);
|
void displayDebugger(DebuggerEngine *engine, bool updateEngine = true);
|
||||||
|
|
||||||
@@ -2370,8 +2370,7 @@ void DebuggerPluginPrivate::runControlFinished(DebuggerEngine *engine)
|
|||||||
m_logWindow->clearUndoRedoStacks();
|
m_logWindow->clearUndoRedoStacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::remoteCommand(const QStringList &options,
|
void DebuggerPluginPrivate::remoteCommand(const QStringList &options)
|
||||||
const QStringList &)
|
|
||||||
{
|
{
|
||||||
if (options.isEmpty())
|
if (options.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -3295,9 +3294,12 @@ IPlugin::ShutdownFlag DebuggerPlugin::aboutToShutdown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QObject *DebuggerPlugin::remoteCommand(const QStringList &options,
|
QObject *DebuggerPlugin::remoteCommand(const QStringList &options,
|
||||||
const QStringList &list)
|
const QString &workingDirectory,
|
||||||
|
const QStringList &list)
|
||||||
{
|
{
|
||||||
dd->remoteCommand(options, list);
|
Q_UNUSED(workingDirectory);
|
||||||
|
Q_UNUSED(list);
|
||||||
|
dd->remoteCommand(options);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,7 +51,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
// IPlugin implementation.
|
// IPlugin implementation.
|
||||||
bool initialize(const QStringList &arguments, QString *errorMessage);
|
bool initialize(const QStringList &arguments, QString *errorMessage);
|
||||||
QObject *remoteCommand(const QStringList &options, const QStringList &arguments);
|
QObject *remoteCommand(const QStringList &options,
|
||||||
|
const QString &workingDirectory,
|
||||||
|
const QStringList &arguments);
|
||||||
ShutdownFlag aboutToShutdown();
|
ShutdownFlag aboutToShutdown();
|
||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user