Commit 17f2af50 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

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: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent facc89fa
......@@ -63,7 +63,9 @@ public:
virtual void extensionsInitialized() = 0;
virtual bool delayedInitialize() { return false; }
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;
PluginSpec *pluginSpec() const;
......
......@@ -505,6 +505,7 @@ QHash<QString, PluginCollection *> PluginManager::pluginCollections()
}
static const char argumentKeywordC[] = ":arguments";
static const char pwdKeywordC[] = ":pwd";
/*!
Serializes plugin options and arguments for sending in a single string
......@@ -528,20 +529,15 @@ QString PluginManager::serializedArguments()
rc += ps->arguments().join(separator);
}
}
if (!rc.isEmpty())
rc += separator;
rc += QLatin1String(pwdKeywordC) + separator + QDir::currentPath();
if (!d->arguments.isEmpty()) {
if (!rc.isEmpty())
rc += separator;
rc += QLatin1String(argumentKeywordC);
// If the argument appears to be a file, make it absolute
// when sending to another instance.
foreach (const QString &argument, d->arguments) {
rc += separator;
const QFileInfo fi(argument);
if (fi.exists() && fi.isRelative())
rc += fi.absoluteFilePath();
else
rc += argument;
}
foreach (const QString &argument, d->arguments)
rc += separator + argument;
}
return rc;
}
......@@ -577,11 +573,14 @@ void PluginManager::remoteArguments(const QString &serializedArgument, QObject *
if (serializedArgument.isEmpty())
return;
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));
foreach (const PluginSpec *ps, plugins()) {
if (ps->state() == PluginSpec::Running) {
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) {
socket->setParent(socketParent);
socket = 0;
......
......@@ -226,17 +226,20 @@ bool CorePlugin::delayedInitialize()
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(
args, ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineNumbers));
args, ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineNumbers),
workingDirectory);
m_mainWindow->raiseWindow();
return res;
}
void CorePlugin::fileOpenRequest(const QString &f)
{
remoteCommand(QStringList(), QStringList(f));
remoteCommand(QStringList(), QString(), QStringList(f));
}
ExtensionSystem::IPlugin::ShutdownFlag CorePlugin::aboutToShutdown()
......
......@@ -59,7 +59,9 @@ public:
void extensionsInitialized();
bool delayedInitialize();
ShutdownFlag aboutToShutdown();
QObject *remoteCommand(const QStringList & /* options */, const QStringList &args);
QObject *remoteCommand(const QStringList & /* options */,
const QString &workingDirectory,
const QStringList &args);
public slots:
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
* 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
* for client mode.
*
* \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>();
IDocument *res = 0;
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();
if (IDocumentFactory *documentFactory = findDocumentFactory(documentFactories, fi)) {
IDocument *document = documentFactory->open(absoluteFilePath);
......
......@@ -94,7 +94,9 @@ public:
void addContextObject(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; }
virtual QPrinter *printer() const;
......
......@@ -737,7 +737,7 @@ public:
void runControlStarted(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);
......@@ -2370,8 +2370,7 @@ void DebuggerPluginPrivate::runControlFinished(DebuggerEngine *engine)
m_logWindow->clearUndoRedoStacks();
}
void DebuggerPluginPrivate::remoteCommand(const QStringList &options,
const QStringList &)
void DebuggerPluginPrivate::remoteCommand(const QStringList &options)
{
if (options.isEmpty())
return;
......@@ -3295,9 +3294,12 @@ IPlugin::ShutdownFlag DebuggerPlugin::aboutToShutdown()
}
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;
}
......
......@@ -51,7 +51,9 @@ public:
private:
// IPlugin implementation.
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();
void extensionsInitialized();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment