mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Fix loading two times a file specified in the command line on OS X
To avoid receiving a she::DropFiles event (from application:openFiles:) when we're loading files specified in the command line (i.e. when we are showing the progress bar/processing "ui" layer events/CustomizedGuiManager is listening for kDropFilesMessages) we call NSApp finishLauching after we've processed the whole command line.
This commit is contained in:
parent
a785c20238
commit
e4c46a761a
@ -658,6 +658,8 @@ void App::initialize(const AppOptions& options)
|
||||
|
||||
LOG("Export sprite sheet: Done\n");
|
||||
}
|
||||
|
||||
she::instance()->finishLaunching();
|
||||
}
|
||||
|
||||
void App::run()
|
||||
|
@ -144,6 +144,10 @@ public:
|
||||
delete this;
|
||||
}
|
||||
|
||||
void finishLaunching() override {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
Capabilities capabilities() const override {
|
||||
return (Capabilities)(Capabilities::CanResizeDisplay);
|
||||
}
|
||||
@ -197,6 +201,7 @@ public:
|
||||
set_color_conversion(old_color_conv);
|
||||
return sur;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
System* create_system() {
|
||||
|
@ -16,10 +16,13 @@ namespace she {
|
||||
|
||||
class OSXApp {
|
||||
public:
|
||||
static OSXApp* instance();
|
||||
|
||||
OSXApp();
|
||||
~OSXApp();
|
||||
|
||||
bool init();
|
||||
void finishLaunching();
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
|
@ -28,23 +28,38 @@ public:
|
||||
[m_app setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
[m_app setDelegate:m_appDelegate];
|
||||
[m_app activateIgnoringOtherApps:YES];
|
||||
[m_app finishLaunching];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void finishLaunching() {
|
||||
[m_app finishLaunching];
|
||||
}
|
||||
|
||||
private:
|
||||
NSApplication* m_app;
|
||||
OSXAppDelegate* m_appDelegate;
|
||||
};
|
||||
|
||||
static OSXApp* g_instance = nullptr;
|
||||
|
||||
// static
|
||||
OSXApp* OSXApp::instance()
|
||||
{
|
||||
return g_instance;
|
||||
}
|
||||
|
||||
OSXApp::OSXApp()
|
||||
: m_impl(new Impl)
|
||||
{
|
||||
ASSERT(!g_instance);
|
||||
g_instance = this;
|
||||
}
|
||||
|
||||
OSXApp::~OSXApp()
|
||||
{
|
||||
ASSERT(g_instance == this);
|
||||
g_instance = nullptr;
|
||||
}
|
||||
|
||||
bool OSXApp::init()
|
||||
@ -52,4 +67,9 @@ bool OSXApp::init()
|
||||
return m_impl->init();
|
||||
}
|
||||
|
||||
void OSXApp::finishLaunching()
|
||||
{
|
||||
m_impl->finishLaunching();
|
||||
}
|
||||
|
||||
} // namespace she
|
||||
|
@ -21,6 +21,7 @@
|
||||
#ifdef _WIN32
|
||||
#include "she/win/event_queue.h"
|
||||
#elif __APPLE__
|
||||
#include "she/osx/app.h"
|
||||
#include "she/osx/event_queue.h"
|
||||
#else
|
||||
#include "she/x11/event_queue.h"
|
||||
@ -51,6 +52,15 @@ public:
|
||||
delete this;
|
||||
}
|
||||
|
||||
void finishLaunching() override {
|
||||
#if __APPLE__
|
||||
// Start processing NSApplicationDelegate events. (E.g. after
|
||||
// calling this we'll receive application:openFiles: and we'll
|
||||
// generate DropFiles events.) events
|
||||
OSXApp::instance()->finishLaunching();
|
||||
#endif
|
||||
}
|
||||
|
||||
Capabilities capabilities() const override {
|
||||
return Capabilities(
|
||||
int(Capabilities::MultipleDisplays) |
|
||||
|
@ -33,6 +33,7 @@ namespace she {
|
||||
public:
|
||||
virtual ~System() { }
|
||||
virtual void dispose() = 0;
|
||||
virtual void finishLaunching() = 0;
|
||||
virtual Capabilities capabilities() const = 0;
|
||||
virtual Logger* logger() = 0;
|
||||
virtual NativeDialogs* nativeDialogs() = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user