mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 13:20:28 +00:00
Fix bug closing the app when it's saving (fix #1326)
This commit is contained in:
parent
c1e3054e3f
commit
617b909e1e
@ -13,6 +13,7 @@
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
#include "app/job.h"
|
||||
#include "app/ui/main_window.h"
|
||||
#include "ui/alert.h"
|
||||
|
||||
@ -36,6 +37,11 @@ ExitCommand::ExitCommand()
|
||||
|
||||
void ExitCommand::onExecute(Context* ctx)
|
||||
{
|
||||
// Ignore ExitCommand when we are saving documents or doing a
|
||||
// background task
|
||||
if (Job::runningJobs() > 0)
|
||||
return;
|
||||
|
||||
if (ctx->hasModifiedDocuments()) {
|
||||
Command* closeAll = CommandsModule::instance()->getCommandByName(CommandId::CloseAllFiles);
|
||||
Params params;
|
||||
|
@ -19,10 +19,19 @@
|
||||
#include "ui/widget.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
static const int kMonitoringPeriod = 100;
|
||||
static std::atomic<int> g_runningJobs(0);
|
||||
|
||||
namespace app {
|
||||
|
||||
// static
|
||||
int Job::runningJobs()
|
||||
{
|
||||
return g_runningJobs;
|
||||
}
|
||||
|
||||
Job::Job(const char* jobName)
|
||||
{
|
||||
m_mutex = NULL;
|
||||
@ -60,6 +69,7 @@ Job::~Job()
|
||||
void Job::startJob()
|
||||
{
|
||||
m_thread = new base::thread(&Job::thread_proc, this);
|
||||
++g_runningJobs;
|
||||
|
||||
if (m_alert_window) {
|
||||
m_alert_window->openWindowInForeground();
|
||||
@ -93,7 +103,9 @@ void Job::waitJob()
|
||||
if (m_thread) {
|
||||
m_thread->join();
|
||||
delete m_thread;
|
||||
m_thread = NULL;
|
||||
m_thread = nullptr;
|
||||
|
||||
--g_runningJobs;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@ namespace app {
|
||||
|
||||
class Job {
|
||||
public:
|
||||
static int runningJobs();
|
||||
|
||||
Job(const char* jobName);
|
||||
virtual ~Job();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user