ui: Fixed escaping and interrupting
* Fixed crash when closing window with ESCAPE * Fixed interrupt status message not showing when interrupting parsing
This commit is contained in:
@@ -25,7 +25,15 @@ void TaskScheduler::pushTask(std::shared_ptr<Task> task)
|
||||
void TaskScheduler::pushNextTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_tasksMutex);
|
||||
m_tasks.push_front(task);
|
||||
|
||||
if (m_tasks.size() == 0)
|
||||
{
|
||||
m_tasks.push_front(task);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tasks.insert(m_tasks.begin() + 1, task);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskScheduler::interruptCurrentTask()
|
||||
@@ -142,15 +150,14 @@ void TaskScheduler::updateTasks()
|
||||
while (m_tasks.size())
|
||||
{
|
||||
std::shared_ptr<Task> task = m_tasks.front();
|
||||
m_tasks.pop_front();
|
||||
|
||||
m_tasksMutex.unlock();
|
||||
Task::TaskState state = task->process(interrupt);
|
||||
m_tasksMutex.lock();
|
||||
|
||||
if (state != Task::STATE_FINISHED && state != Task::STATE_CANCELED)
|
||||
if (state == Task::STATE_FINISHED || state == Task::STATE_CANCELED)
|
||||
{
|
||||
m_tasks.push_front(task);
|
||||
m_tasks.pop_front();
|
||||
}
|
||||
|
||||
interrupt = m_interruptTask;
|
||||
|
||||
@@ -483,7 +483,6 @@ void QtMainWindow::toggleView(View* view, bool fromMenu)
|
||||
|
||||
void QtMainWindow::handleEscapeShortcut()
|
||||
{
|
||||
m_windowStack.popWindow();
|
||||
MessageInterruptTasks().dispatch();
|
||||
}
|
||||
|
||||
|
||||
@@ -260,6 +260,7 @@ void QtWindow::keyPressEvent(QKeyEvent *event)
|
||||
if (m_cancelAble && event->key() == Qt::Key_Escape)
|
||||
{
|
||||
emit canceled();
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget::keyPressEvent(event);
|
||||
|
||||
Reference in New Issue
Block a user