Merge branch 'Akebi-Group:master' into 2.7

This commit is contained in:
Taiga 2022-05-30 12:49:42 -07:00 committed by GitHub
commit 4e95300b9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -63,6 +63,12 @@ struct EventCore
{ {
using TMyHandlerPtr = typename TypeHelper<TParams...>::TEventHandlerPtr; using TMyHandlerPtr = typename TypeHelper<TParams...>::TEventHandlerPtr;
EventCore() {}
EventCore(const EventCore<TParams...>& other) : handlers(other.handlers) {}
EventCore(EventCore<TParams...>&& other) : handlers(std::move(handlers)) {}
EventCore<TParams...>& operator=(const EventCore<TParams...>& other) { handlers = other.handlers; return *this; }
EventCore<TParams...>& operator=(EventCore<TParams...>&& other) { handlers = std::move(other.handlers); return *this; }
std::list<TMyHandlerPtr> handlers; std::list<TMyHandlerPtr> handlers;
mutable std::shared_mutex coreMutex; mutable std::shared_mutex coreMutex;
}; };
@ -126,6 +132,11 @@ class TEvent : public IEvent<TParams...>
{ {
} }
TEvent(const TEvent& other) : m_core(other.m_core), m_handlerRunners(other.m_handlerRunners)
{
}
virtual void operator()( TParams... params ) virtual void operator()( TParams... params )
{ {
TMyHandlerRunner newHandlerRunner( m_core ); TMyHandlerRunner newHandlerRunner( m_core );

View File

@ -3,6 +3,7 @@
#include "util.h" #include "util.h"
#include <Windows.h> #include <Windows.h>
#include <shellapi.h>
#include <commdlg.h> #include <commdlg.h>
#include <shtypes.h> #include <shtypes.h>
#include <shobjidl_core.h> #include <shobjidl_core.h>
@ -270,4 +271,9 @@ namespace util
return static_cast<int64_t>(timezoneInfo.Bias) * 60; return static_cast<int64_t>(timezoneInfo.Bias) * 60;
} }
void OpenURL(const char* url)
{
ShellExecute(nullptr, nullptr, url, nullptr, nullptr, SW_SHOW);
}
} }

View File

@ -32,6 +32,7 @@ namespace util
std::optional<std::string> SelectDirectory(const char* title); std::optional<std::string> SelectDirectory(const char* title);
std::optional<std::string> GetOrSelectPath(CSimpleIni& ini, const char* section, const char* name, const char* friendName, const char* filter); std::optional<std::string> GetOrSelectPath(CSimpleIni& ini, const char* section, const char* name, const char* friendName, const char* filter);
void OpenURL(const char* url);
std::string GetLastErrorAsString(DWORD errorId = 0); std::string GetLastErrorAsString(DWORD errorId = 0);
int64_t GetCurrentTimeMillisec(); int64_t GetCurrentTimeMillisec();