summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-08-30 00:48:59 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-09-15 16:14:19 +0200
commit3d8802e235e9508a0bf3d8a1168ad11c95571579 (patch)
tree6472bbd934dea6081b5a5ab1464989d4f8cec8df
parent6b09016f5d9119729265211db6cc91f991fc3e28 (diff)
downloadsink-3d8802e235e9508a0bf3d8a1168ad11c95571579.tar.gz
sink-3d8802e235e9508a0bf3d8a1168ad11c95571579.zip
Also call commandFinished in the error case.
-rw-r--r--sinksh/state.cpp4
-rw-r--r--sinksh/syntax_modules/sink_sync.cpp8
2 files changed, 10 insertions, 2 deletions
diff --git a/sinksh/state.cpp b/sinksh/state.cpp
index 6fce21f..8f4a675 100644
--- a/sinksh/state.cpp
+++ b/sinksh/state.cpp
@@ -26,6 +26,8 @@
26 26
27#include "common/log.h" 27#include "common/log.h"
28 28
29SINK_DEBUG_AREA("state")
30
29static bool s_hasEventLoop = false; 31static bool s_hasEventLoop = false;
30 32
31class State::Private 33class State::Private
@@ -127,6 +129,7 @@ unsigned int State::debugLevel() const
127 129
128int State::commandStarted() const 130int State::commandStarted() const
129{ 131{
132 SinkTrace() << "Command started";
130 if (!s_hasEventLoop) { 133 if (!s_hasEventLoop) {
131 return QCoreApplication::exec(); 134 return QCoreApplication::exec();
132 } else if (!d->eventLoop()->isRunning()) { 135 } else if (!d->eventLoop()->isRunning()) {
@@ -138,6 +141,7 @@ int State::commandStarted() const
138 141
139void State::commandFinished(int returnCode) const 142void State::commandFinished(int returnCode) const
140{ 143{
144 SinkTrace() << "Command finished";
141 if (!s_hasEventLoop) { 145 if (!s_hasEventLoop) {
142 QCoreApplication::exit(returnCode); 146 QCoreApplication::exit(returnCode);
143 } else { 147 } else {
diff --git a/sinksh/syntax_modules/sink_sync.cpp b/sinksh/syntax_modules/sink_sync.cpp
index 2ed4cf7..e3c51ff 100644
--- a/sinksh/syntax_modules/sink_sync.cpp
+++ b/sinksh/syntax_modules/sink_sync.cpp
@@ -45,8 +45,12 @@ bool sync(const QStringList &args, State &state)
45 } 45 }
46 46
47 QTimer::singleShot(0, [query, state]() { 47 QTimer::singleShot(0, [query, state]() {
48 Sink::Store::synchronize(query).syncThen<void>([state]() { 48 Sink::Store::synchronize(query).syncThen<void>([state](const KAsync::Error &error) {
49 state.printLine("Synchronization complete!"); 49 if (error) {
50 state.printLine("Synchronization failed!");
51 } else {
52 state.printLine("Synchronization complete!");
53 }
50 state.commandFinished(); 54 state.commandFinished();
51 }).exec(); 55 }).exec();
52 }); 56 });