forked from qt-creator/qt-creator
VcsCommand: Change the default logic for fully sync
Remove VcsCommand::FullySynchronous flag. Rename VcsCommand::NoFullySync into UseEventLoop. By default the command will run fully synchronous (i.e. without nested event loop). Only when UseEventLoop is specified, and the command runs in main thread, the nested event loop will be used. This change should preserve the current behavior on all code paths. Change-Id: Id4bbaf68402ceed5e3fcc6f294521e87eb0b8d4d Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -86,7 +86,7 @@ public:
|
||||
void cleanup();
|
||||
void setupProcess(QtcProcess *process, const Job &job);
|
||||
void installStdCallbacks(QtcProcess *process);
|
||||
bool isFullySynchronous() const;
|
||||
EventLoopMode eventLoopMode() const;
|
||||
void handleDone(QtcProcess *process);
|
||||
void startAll();
|
||||
void startNextJob();
|
||||
@@ -214,10 +214,11 @@ void VcsCommandPrivate::installStdCallbacks(QtcProcess *process)
|
||||
// m_process->setTimeOutMessageBoxEnabled(true);
|
||||
}
|
||||
|
||||
bool VcsCommandPrivate::isFullySynchronous() const
|
||||
EventLoopMode VcsCommandPrivate::eventLoopMode() const
|
||||
{
|
||||
return (m_flags & VcsCommand::FullySynchronously) || (!(m_flags & VcsCommand::NoFullySync)
|
||||
&& QThread::currentThread() == QCoreApplication::instance()->thread());
|
||||
if ((m_flags & VcsCommand::UseEventLoop) && QThread::currentThread() == qApp->thread())
|
||||
return EventLoopMode::On;
|
||||
return EventLoopMode::Off;
|
||||
}
|
||||
|
||||
void VcsCommandPrivate::handleDone(QtcProcess *process)
|
||||
@@ -392,9 +393,8 @@ CommandResult VcsCommand::runCommand(const CommandLine &command, int timeoutS)
|
||||
|
||||
d->setupProcess(&process, {command, timeoutS, d->m_defaultWorkingDirectory, {}});
|
||||
|
||||
EventLoopMode eventLoopMode = EventLoopMode::Off;
|
||||
if (!d->isFullySynchronous()) {
|
||||
eventLoopMode = EventLoopMode::On;
|
||||
const EventLoopMode eventLoopMode = d->eventLoopMode();
|
||||
if (eventLoopMode == EventLoopMode::On) {
|
||||
connect(this, &VcsCommand::terminate, &process, [&process] {
|
||||
process.stop();
|
||||
process.waitForFinished();
|
||||
|
||||
@@ -90,11 +90,9 @@ public:
|
||||
SuppressCommandLogging = 0x10, // No command log entry.
|
||||
ShowSuccessMessage = 0x20, // Show message about successful completion of command.
|
||||
ForceCLocale = 0x40, // Force C-locale for commands whose output is parsed.
|
||||
FullySynchronously = 0x80, // Suppress local event loop (in case UI actions are
|
||||
// triggered by file watchers).
|
||||
SilentOutput = 0x100, // Suppress user notifications about the output happening.
|
||||
NoFullySync = 0x200, // Avoid fully synchronous execution even in UI thread.
|
||||
ExpectRepoChanges = 0x400, // Expect changes in repository by the command
|
||||
SilentOutput = 0x80, // Suppress user notifications about the output happening.
|
||||
UseEventLoop = 0x100, // Use event loop when executed in UI thread.
|
||||
ExpectRepoChanges = 0x200, // Expect changes in repository by the command
|
||||
NoOutput = SuppressStdErr | SuppressFailMessage | SuppressCommandLogging
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user