diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 7d7367c8..47366b72 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -199,13 +199,13 @@ MainWindow::MainWindow(QWidget *parent) , m(new Private) { ui->setupUi(this); + ui->frame_progress->setVisible(false); setupShowFileListHandler(); setupProgressHandler(); setupAddFileObjectData(); setUnknownRepositoryInfo(); - hideProgress(); ui->frame_repository_wrapper->bind(this , ui->tableWidget_log @@ -3228,23 +3228,32 @@ bool MainWindow::fetch(GitPtr g, bool prune) { bool ret = false; - std::thread th([&](GitPtr g, bool prune){ + struct FetchParams { + PtyProcess *pty = nullptr; + GitPtr g; + bool prune; + }; + FetchParams params; + params.g = g; + params.prune = prune; + + auto Func = [&](FetchParams params){ + params.g->fetch(params.pty, params.prune); + }; + + std::thread th([&](FetchParams params){ setProgress(-1.0f); showProgress(tr("Fetching..."), false); setPtyCondition(PtyCondition::Fetch); setPtyProcessOk(true); - PtyProcess *pty = getPtyProcess(); - // std::thread th2([this, g, prune, pty](){ - g->fetch(pty, prune); - // }); - while (1) { - if (pty->wait(1)) break; - QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - } - // th2.join(); + params.pty = getPtyProcess(); + + Func(params); + + while (!params.pty->wait(1)); ret = getPtyProcessOk(); hideProgress(); - }, g, prune); + }, params); th.join(); return ret; diff --git a/src/win32/Win32PtyProcess.cpp b/src/win32/Win32PtyProcess.cpp index a0fb5e96..1c4bbb1f 100644 --- a/src/win32/Win32PtyProcess.cpp +++ b/src/win32/Win32PtyProcess.cpp @@ -235,7 +235,8 @@ void Win32PtyProcess::start(QString const &cmdline, QString const &env, QVariant bool Win32PtyProcess::wait(unsigned long time) { - return QThread::wait(time) && m->th_output_reader.wait(time); + std::this_thread::sleep_for(std::chrono::milliseconds(time)); + return m->th_output_reader.wait(time); } void Win32PtyProcess::stop()