diff --git a/laf b/laf index 243fe983a..4c588f967 160000 --- a/laf +++ b/laf @@ -1 +1 @@ -Subproject commit 243fe983a984e49ded14bb953eae9b75b194b095 +Subproject commit 4c588f96774b6d651ae3d6ca70e97f7e290011af diff --git a/src/app/check_update.cpp b/src/app/check_update.cpp index 6490cacf0..f9123b3d2 100644 --- a/src/app/check_update.cpp +++ b/src/app/check_update.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020-2021 Igara Studio S.A. +// Copyright (C) 2020-2023 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -135,7 +135,7 @@ void CheckUpdateThreadLauncher::launch() m_delegate->onCheckingUpdates(); m_bgJob.reset(new CheckUpdateBackgroundJob); - m_thread.reset(new base::thread([this]{ checkForUpdates(); })); + m_thread.reset(new std::thread([this]{ checkForUpdates(); })); // Start a timer to monitoring the progress of the background job // executed in "m_thread". The "onMonitoringTick" method will be diff --git a/src/app/check_update.h b/src/app/check_update.h index 7f805173b..ec713cc19 100644 --- a/src/app/check_update.h +++ b/src/app/check_update.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020 Igara Studio S.A. +// Copyright (C) 2020-2023 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -11,12 +11,12 @@ #ifdef ENABLE_UPDATER -#include "base/thread.h" #include "ui/timer.h" #include "updater/check_update.h" #include #include +#include namespace app { @@ -46,7 +46,7 @@ namespace app { CheckUpdateDelegate* m_delegate; Preferences& m_preferences; updater::Uuid m_uuid; - std::unique_ptr m_thread; + std::unique_ptr m_thread; std::unique_ptr m_bgJob; bool m_doCheck; std::atomic m_received; diff --git a/src/app/commands/cmd_change_pixel_format.cpp b/src/app/commands/cmd_change_pixel_format.cpp index abc2db23d..2819a90f9 100644 --- a/src/app/commands/cmd_change_pixel_format.cpp +++ b/src/app/commands/cmd_change_pixel_format.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2022 Igara Studio S.A. +// Copyright (C) 2019-2023 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -27,7 +27,6 @@ #include "app/ui/editor/editor_render.h" #include "app/ui/rgbmap_algorithm_selector.h" #include "app/ui/skin/skin_theme.h" -#include "base/thread.h" #include "doc/image.h" #include "doc/layer.h" #include "doc/sprite.h" @@ -43,7 +42,9 @@ #include "ui/size_hint_event.h" #include "color_mode.xml.h" + #include +#include namespace app { @@ -161,7 +162,7 @@ private: bool m_running; bool m_stopFlag; double m_progress; - base::thread m_thread; + std::thread m_thread; }; #ifdef ENABLE_UI diff --git a/src/app/commands/filters/filter_preview.cpp b/src/app/commands/filters/filter_preview.cpp index d378c8835..502949b8f 100644 --- a/src/app/commands/filters/filter_preview.cpp +++ b/src/app/commands/filters/filter_preview.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2022 Igara Studio S.A. +// Copyright (C) 2019-2023 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -14,12 +14,15 @@ #include "app/commands/filters/filter_manager_impl.h" #include "app/ui/editor/editor.h" #include "app/ui/editor/editor_render.h" +#include "base/thread.h" #include "doc/layer.h" #include "doc/sprite.h" #include "ui/manager.h" #include "ui/message.h" #include "ui/widget.h" +#include + namespace app { using namespace ui; @@ -84,7 +87,7 @@ void FilterPreview::restartPreview() m_filterIsDone = false; m_timer.start(); m_filterThread.reset( - new base::thread([this]{ onFilterThread(); })); + new std::thread([this]{ onFilterThread(); })); } bool FilterPreview::onProcessMessage(Message* msg) diff --git a/src/app/commands/filters/filter_preview.h b/src/app/commands/filters/filter_preview.h index 6b5e9bc70..68e4b9c56 100644 --- a/src/app/commands/filters/filter_preview.h +++ b/src/app/commands/filters/filter_preview.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2022 Igara Studio S.A. +// Copyright (C) 2022-2023 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -9,11 +9,11 @@ #define APP_COMMANDS_FILTERS_FILTER_PREVIEW_H_INCLUDED #pragma once -#include "base/thread.h" #include "ui/timer.h" #include "ui/widget.h" #include +#include namespace app { @@ -39,7 +39,7 @@ namespace app { FilterManagerImpl* m_filterMgr; ui::Timer m_timer; std::mutex m_filterMgrMutex; - std::unique_ptr m_filterThread; + std::unique_ptr m_filterThread; bool m_filterIsDone; }; diff --git a/src/app/errno_tests.cpp b/src/app/errno_tests.cpp index 153aa31bd..00aa01257 100644 --- a/src/app/errno_tests.cpp +++ b/src/app/errno_tests.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2023 Igara Studio S.A. // Copyright (C) 2001-2015 David Capello // // This program is distributed under the terms of @@ -6,8 +7,8 @@ #include "tests/app_test.h" -#include -#include "base/thread.h" +#include +#include static void run_thread() { @@ -22,7 +23,7 @@ TEST(Errno, ThreadSafe) // Run another thread that will be modify the errno variable, and // wait it (join). - base::thread thr(&run_thread); + std::thread thr(&run_thread); thr.join(); // See if errno was not modified in this thread. diff --git a/src/app/res/http_loader.h b/src/app/res/http_loader.h index abe14e8e9..a4f7c110d 100644 --- a/src/app/res/http_loader.h +++ b/src/app/res/http_loader.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2022 Igara Studio S.A. +// Copyright (C) 2022-2023 Igara Studio S.A. // Copyright (C) 2001-2016 David Capello // // This program is distributed under the terms of @@ -9,10 +9,9 @@ #define APP_RES_HTTP_LOADER_H_INCLUDED #pragma once -#include "base/thread.h" - #include #include +#include namespace net { class HttpRequest; @@ -35,7 +34,7 @@ namespace app { std::string m_url; std::atomic m_done; net::HttpRequest* m_request; - base::thread m_thread; + std::thread m_thread; std::string m_filename; }; diff --git a/src/app/res/resources_loader.cpp b/src/app/res/resources_loader.cpp index 1dc4dc61d..6b0eefbf1 100644 --- a/src/app/res/resources_loader.cpp +++ b/src/app/res/resources_loader.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020 Igara Studio S.A. +// Copyright (C) 2020-2023 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -24,7 +24,7 @@ ResourcesLoader::ResourcesLoader(std::unique_ptr&& dele : m_delegate(std::move(delegate)) , m_done(false) , m_cancel(false) - , m_thread(new base::thread([this]{ threadLoadResources(); })) + , m_thread(new std::thread([this]{ threadLoadResources(); })) { } @@ -83,9 +83,9 @@ void ResourcesLoader::threadLoadResources() } } -base::thread* ResourcesLoader::createThread() +std::thread* ResourcesLoader::createThread() { - return new base::thread([this]{ threadLoadResources(); }); + return new std::thread([this]{ threadLoadResources(); }); } } // namespace app diff --git a/src/app/res/resources_loader.h b/src/app/res/resources_loader.h index a7c9ae14a..5db9fde0b 100644 --- a/src/app/res/resources_loader.h +++ b/src/app/res/resources_loader.h @@ -10,9 +10,9 @@ #pragma once #include "base/concurrent_queue.h" -#include "base/thread.h" #include +#include namespace app { @@ -31,7 +31,7 @@ namespace app { private: void threadLoadResources(); - base::thread* createThread(); + std::thread* createThread(); typedef base::concurrent_queue Queue; @@ -39,7 +39,7 @@ namespace app { bool m_done; bool m_cancel; Queue m_queue; - std::unique_ptr m_thread; + std::unique_ptr m_thread; }; } // namespace app diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index 64ddc5274..8a0f56fe4 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2018-2022 Igara Studio S.A. +// Copyright (C) 2018-2023 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This file is released under the terms of the MIT license. @@ -20,6 +20,7 @@ #include "base/concurrent_queue.h" #include "base/scoped_value.h" +#include "base/thread.h" #include "base/time.h" #include "os/event.h" #include "os/event_queue.h" @@ -31,7 +32,7 @@ #include "ui/ui.h" #if defined(DEBUG_PAINT_EVENTS) || defined(DEBUG_UI_THREADS) -#include "base/thread.h" +#include #endif #include @@ -82,7 +83,7 @@ typedef std::list Filters; Manager* Manager::m_defaultManager = nullptr; #ifdef DEBUG_UI_THREADS -static base::thread::native_id_type manager_thread = 0; +static std::thread::id manager_thread; #endif static WidgetsList mouse_widgets_list; // List of widgets to send mouse events @@ -208,8 +209,8 @@ Manager::Manager(const os::WindowRef& nativeWindow) nativeWindow->setUserData(&m_display); #ifdef DEBUG_UI_THREADS - ASSERT(!manager_thread); - manager_thread = base::this_thread::native_id(); + ASSERT(manager_thread == std::thread::id()); + manager_thread = std::this_thread::get_id(); #endif if (!m_defaultManager) { @@ -237,7 +238,7 @@ Manager::Manager(const os::WindowRef& nativeWindow) Manager::~Manager() { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif // There are some messages in queue? Dispatch everything. @@ -332,7 +333,7 @@ void Manager::updateAllDisplaysWithNewScale(int scale) bool Manager::generateMessages() { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif // First check: there are windows to manage? @@ -398,7 +399,7 @@ static MouseButton mouse_button_from_os_to_ui(const os::Event& osEvent) void Manager::generateMessagesFromOSEvents() { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif os::Event lastMouseMoveEvent; @@ -1100,7 +1101,7 @@ void Manager::freeCapture() void Manager::freeWidget(Widget* widget) { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif if (widget->hasFocus() || (widget == focus_widget)) @@ -1131,7 +1132,7 @@ void Manager::freeWidget(Widget* widget) void Manager::removeMessagesFor(Widget* widget) { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif for (Message* msg : msg_queue) @@ -1144,7 +1145,7 @@ void Manager::removeMessagesFor(Widget* widget) void Manager::removeMessagesFor(Widget* widget, MessageType type) { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif for (Message* msg : msg_queue) @@ -1159,7 +1160,7 @@ void Manager::removeMessagesFor(Widget* widget, MessageType type) void Manager::removeMessagesForTimer(Timer* timer) { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif for (Message* msg : msg_queue) { @@ -1182,7 +1183,7 @@ void Manager::removeMessagesForTimer(Timer* timer) void Manager::removeMessagesForDisplay(Display* display) { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif for (Message* msg : msg_queue) { @@ -1203,7 +1204,7 @@ void Manager::removeMessagesForDisplay(Display* display) void Manager::removePaintMessagesForDisplay(Display* display) { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif for (auto it=msg_queue.begin(); it != msg_queue.end(); ) { @@ -1221,7 +1222,7 @@ void Manager::removePaintMessagesForDisplay(Display* display) void Manager::addMessageFilter(int message, Widget* widget) { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif LockFilters lock; @@ -1235,7 +1236,7 @@ void Manager::addMessageFilter(int message, Widget* widget) void Manager::removeMessageFilter(int message, Widget* widget) { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif LockFilters lock; @@ -1253,7 +1254,7 @@ void Manager::removeMessageFilter(int message, Widget* widget) void Manager::removeMessageFilterFor(Widget* widget) { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif LockFilters lock; @@ -1802,7 +1803,7 @@ void Manager::onSizeHint(SizeHintEvent& ev) int Manager::pumpQueue() { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif #ifdef LIMIT_DISPATCH_TIME @@ -1876,7 +1877,7 @@ int Manager::pumpQueue() bool Manager::sendMessageToWidget(Message* msg, Widget* widget) { #ifdef DEBUG_UI_THREADS - ASSERT(manager_thread == base::this_thread::native_id()); + ASSERT(manager_thread == std::this_thread::get_id()); #endif if (!widget) @@ -1953,7 +1954,7 @@ bool Manager::sendMessageToWidget(Message* msg, Widget* widget) #ifdef DEBUG_PAINT_EVENTS { - os::SurfaceLock lock(surface); + os::SurfaceLock lock(surface.get()); os::Paint p; p.color(gfx::rgba(0, 0, 255)); p.style(os::Paint::Fill); diff --git a/src/ui/system.cpp b/src/ui/system.cpp index ea721fe24..81b892de9 100644 --- a/src/ui/system.cpp +++ b/src/ui/system.cpp @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2018-2021 Igara Studio S.A. +// Copyright (C) 2018-2023 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This file is released under the terms of the MIT license. @@ -11,7 +11,6 @@ #include "ui/system.h" -#include "base/thread.h" #include "gfx/point.h" #include "os/event.h" #include "os/event_queue.h" @@ -29,11 +28,13 @@ #include "ui/theme.h" #include "ui/widget.h" +#include + namespace ui { // This is used to check if calls to UI layer are made from the non-UI // thread. (Which might be catastrofic.) -base::thread::native_id_type main_gui_thread; +std::thread::id main_gui_thread; // Multiple displays (create one os::Window for each ui::Window) bool multi_displays = false; @@ -218,7 +219,7 @@ UISystem::UISystem() ASSERT(!g_instance); g_instance = this; - main_gui_thread = base::this_thread::native_id(); + main_gui_thread = std::this_thread::get_id(); mouse_cursor_type = kOutsideDisplay; support_native_custom_cursor = ((os::instance() && @@ -379,7 +380,7 @@ void execute_from_ui_thread(std::function&& func) bool is_ui_thread() { - return (main_gui_thread == base::this_thread::native_id()); + return (main_gui_thread == std::this_thread::get_id()); } #ifdef _DEBUG