Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
770fc594
Commit
770fc594
authored
Dec 13, 2010
by
con
Browse files
Don't ask for reload if external tool claims to change current document
Take it as an expected file change.
parent
1d1a5a70
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/coreplugin/externaltool.cpp
View file @
770fc594
...
...
@@ -36,6 +36,9 @@
#include
<coreplugin/icore.h>
#include
<coreplugin/messagemanager.h>
#include
<coreplugin/filemanager.h>
#include
<coreplugin/editormanager/editormanager.h>
#include
<coreplugin/editormanager/ieditor.h>
#include
<utils/qtcassert.h>
#include
<utils/stringutils.h>
#include
<utils/environment.h>
...
...
@@ -334,12 +337,16 @@ void ExternalToolRunner::run()
}
if
(
m_tool
->
outputHandling
()
==
ExternalTool
::
ReloadDocument
||
m_tool
->
errorHandling
()
==
ExternalTool
::
ReloadDocument
)
{
// TODO ask modified file to save, block modification notifications
// TODO ask modified file to save
if
(
IEditor
*
editor
=
EditorManager
::
instance
()
->
currentEditor
())
{
m_expectedFileName
=
editor
->
file
()
->
fileName
();
FileManager
::
instance
()
->
expectFileChange
(
m_expectedFileName
);
}
}
m_process
=
new
QProcess
;
// TODO error handling, finish reporting, reading output, etc
connect
(
m_process
,
SIGNAL
(
started
()),
this
,
SLOT
(
started
()));
connect
(
m_process
,
SIGNAL
(
finished
(
int
)),
this
,
SLOT
(
finished
()));
connect
(
m_process
,
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
finished
(
int
,
QProcess
::
ExitStatus
)));
connect
(
m_process
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SLOT
(
error
(
QProcess
::
ProcessError
)));
connect
(
m_process
,
SIGNAL
(
readyReadStandardOutput
()),
this
,
SLOT
(
readStandardOutput
()));
connect
(
m_process
,
SIGNAL
(
readyReadStandardError
()),
this
,
SLOT
(
readStandardError
()));
...
...
@@ -358,24 +365,29 @@ void ExternalToolRunner::started()
m_process
->
closeWriteChannel
();
}
void
ExternalToolRunner
::
finished
()
void
ExternalToolRunner
::
finished
(
int
exitCode
,
QProcess
::
ExitStatus
status
)
{
if
(
m_tool
->
outputHandling
()
==
ExternalTool
::
ReplaceSelection
||
m_tool
->
errorHandling
()
==
ExternalTool
::
ReplaceSelection
)
{
emit
ExternalToolManager
::
instance
()
->
replaceSelectionRequested
(
m_processOutput
);
}
else
if
(
m_tool
->
outputHandling
()
==
ExternalTool
::
ReloadDocument
||
m_tool
->
errorHandling
()
==
ExternalTool
::
ReloadDocument
)
{
// TODO reload document without popup
if
(
status
==
QProcess
::
NormalExit
&&
exitCode
==
0
)
{
if
(
m_tool
->
outputHandling
()
==
ExternalTool
::
ReplaceSelection
||
m_tool
->
errorHandling
()
==
ExternalTool
::
ReplaceSelection
)
{
emit
ExternalToolManager
::
instance
()
->
replaceSelectionRequested
(
m_processOutput
);
}
else
if
(
m_tool
->
outputHandling
()
==
ExternalTool
::
ReloadDocument
||
m_tool
->
errorHandling
()
==
ExternalTool
::
ReloadDocument
)
{
FileManager
::
instance
()
->
unexpectFileChange
(
m_expectedFileName
);
}
}
ICore
::
instance
()
->
messageManager
()
->
printToOutputPane
(
tr
(
"'%1' finished"
).
arg
(
m_resolvedExecutable
),
false
);
// TODO handle the ReplaceSelection and ReloadDocument flags
m_process
->
deleteLater
();
deleteLater
();
}
void
ExternalToolRunner
::
error
(
QProcess
::
ProcessError
error
)
{
if
(
m_tool
->
outputHandling
()
==
ExternalTool
::
ReloadDocument
||
m_tool
->
errorHandling
()
==
ExternalTool
::
ReloadDocument
)
{
FileManager
::
instance
()
->
unexpectFileChange
(
m_expectedFileName
);
}
// TODO inform about errors
m_process
->
deleteLater
();
deleteLater
();
...
...
src/plugins/coreplugin/externaltool.h
View file @
770fc594
...
...
@@ -94,7 +94,7 @@ public:
private
slots
:
void
started
();
void
finished
();
void
finished
(
int
exitCode
,
QProcess
::
ExitStatus
status
);
void
error
(
QProcess
::
ProcessError
error
);
void
readStandardOutput
();
void
readStandardError
();
...
...
@@ -113,6 +113,7 @@ private:
QTextCodec
::
ConverterState
m_outputCodecState
;
QTextCodec
::
ConverterState
m_errorCodecState
;
QString
m_processOutput
;
QString
m_expectedFileName
;
};
}
// Internal
...
...
src/plugins/coreplugin/filemanager.cpp
View file @
770fc594
...
...
@@ -120,6 +120,7 @@ struct FileManagerPrivate {
QStringList
m_changedFiles
;
QList
<
IFile
*>
m_filesWithoutWatch
;
QMap
<
IFile
*
,
QStringList
>
m_filesWithWatch
;
QSet
<
QString
>
m_expectedFileNames
;
QList
<
FileManager
::
RecentFile
>
m_recentFiles
;
static
const
int
m_maxRecentFiles
=
7
;
...
...
@@ -514,8 +515,9 @@ void FileManager::unblockFileChange(IFile *file)
*/
void
FileManager
::
expectFileChange
(
const
QString
&
fileName
)
{
// Nothing to do
Q_UNUSED
(
fileName
);
if
(
fileName
.
isEmpty
())
return
;
d
->
m_expectedFileNames
.
insert
(
fileName
);
}
/*!
...
...
@@ -534,6 +536,7 @@ void FileManager::unexpectFileChange(const QString &fileName)
if
(
fileName
.
isEmpty
())
return
;
d
->
m_expectedFileNames
.
remove
(
fileName
);
const
QString
fixedName
=
fixFileName
(
fileName
,
KeepLinks
);
updateExpectedState
(
fixedName
);
const
QString
fixedResolvedName
=
fixFileName
(
fileName
,
ResolveLinks
);
...
...
@@ -864,6 +867,19 @@ void FileManager::checkForReload()
changedIFiles
.
insert
(
file
);
}
// collect information about "expected" file names
// we can't do the "resolving" already in expectFileChange, because
// if the resolved names are different when unexpectFileChange is called
// we would end up with never-unexpected file names
QSet
<
QString
>
expectedFileNames
;
foreach
(
const
QString
&
fileName
,
d
->
m_expectedFileNames
)
{
const
QString
fixedName
=
fixFileName
(
fileName
,
KeepLinks
);
expectedFileNames
.
insert
(
fixedName
);
const
QString
fixedResolvedName
=
fixFileName
(
fileName
,
ResolveLinks
);
if
(
fixedName
!=
fixedResolvedName
)
expectedFileNames
.
insert
(
fixedResolvedName
);
}
// handle the IFiles
foreach
(
IFile
*
file
,
changedIFiles
)
{
IFile
::
ChangeTrigger
behavior
=
IFile
::
TriggerInternal
;
...
...
@@ -890,7 +906,8 @@ void FileManager::checkForReload()
continue
;
// was the change unexpected?
if
(
currentState
.
modified
!=
expectedState
.
modified
||
currentState
.
permissions
!=
expectedState
.
permissions
)
{
if
((
currentState
.
modified
!=
expectedState
.
modified
||
currentState
.
permissions
!=
expectedState
.
permissions
)
&&
!
expectedFileNames
.
contains
(
fileName
))
{
behavior
=
IFile
::
TriggerExternal
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment