mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-18 02:52:10 +00:00
Revert "FIX: support auto-reconnect for MAC power awake"
This reverts commit bb13f1e904.
This commit is contained in:
@@ -2222,71 +2222,8 @@ void GUI_App::init_single_instance_checker(const std::string &name, const std::s
|
|||||||
m_single_instance_checker = std::make_unique<wxSingleInstanceChecker>(boost::nowide::widen(name), boost::nowide::widen(path));
|
m_single_instance_checker = std::make_unique<wxSingleInstanceChecker>(boost::nowide::widen(name), boost::nowide::widen(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
void GUI_App::MacPowerCallBack(void* refcon, io_service_t service, natural_t messageType, void * messageArgument)
|
|
||||||
{
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "MacPowerCallBack messageType:" << messageType;
|
|
||||||
|
|
||||||
DeviceManager* dev_manager = wxGetApp().getDeviceManager();
|
|
||||||
|
|
||||||
static std::string last_selected_machine;
|
|
||||||
if (messageType == kIOMessageSystemWillSleep)
|
|
||||||
{
|
|
||||||
if (dev_manager)
|
|
||||||
{
|
|
||||||
MachineObject* obj = dev_manager->get_selected_machine();
|
|
||||||
last_selected_machine = obj ? obj->dev_id : "";
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "MacPowerCallBack save selected machine:" << last_selected_machine;
|
|
||||||
}
|
|
||||||
|
|
||||||
IOAllowPowerChange(service, (long) messageArgument);
|
|
||||||
}
|
|
||||||
else if(messageType == kIOMessageSystemHasPoweredOn)
|
|
||||||
{
|
|
||||||
if (dev_manager && !last_selected_machine.empty())
|
|
||||||
{
|
|
||||||
dev_manager->set_selected_machine(last_selected_machine, true);
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "MacPowerCallBack restore selected machine:" << last_selected_machine;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GUI_App::RegisterMacPowerCallBack()
|
|
||||||
{
|
|
||||||
m_mac_io_service = IORegisterForSystemPower(m_mac_refcon, &m_mac_io_notify_port, MacPowerCallBack, &m_mac_io_obj);
|
|
||||||
if (m_mac_io_service == 0)
|
|
||||||
{
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "RegisterMacPowerCallBack failed";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(m_mac_io_notify_port), kCFRunLoopCommonModes);
|
|
||||||
m_mac_powercallback_registered = true;
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "RegisterMacPowerCallBack success";
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI_App::UnRegisterMacPowerCallBack()
|
|
||||||
{
|
|
||||||
if (m_mac_powercallback_registered)
|
|
||||||
{
|
|
||||||
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(m_mac_io_notify_port), kCFRunLoopCommonModes);
|
|
||||||
IODeregisterForSystemPower(&m_mac_io_obj);
|
|
||||||
IOServiceClose(m_mac_io_service);
|
|
||||||
IONotificationPortDestroy(m_mac_io_notify_port);
|
|
||||||
m_mac_powercallback_registered = false;
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "UnRegisterMacPowerCallBack";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool GUI_App::OnInit()
|
bool GUI_App::OnInit()
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
|
||||||
RegisterMacPowerCallBack();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return on_init_inner();
|
return on_init_inner();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
@@ -2298,10 +2235,6 @@ bool GUI_App::OnInit()
|
|||||||
|
|
||||||
int GUI_App::OnExit()
|
int GUI_App::OnExit()
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
|
||||||
UnRegisterMacPowerCallBack();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
stop_sync_user_preset();
|
stop_sync_user_preset();
|
||||||
|
|
||||||
if (m_device_manager) {
|
if (m_device_manager) {
|
||||||
|
|||||||
@@ -29,11 +29,6 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
|
||||||
#include <IOKit/IOMessage.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define BBL_HAS_FIRST_PAGE 1
|
//#define BBL_HAS_FIRST_PAGE 1
|
||||||
#define STUDIO_INACTIVE_TIMEOUT 15*60*1000
|
#define STUDIO_INACTIVE_TIMEOUT 15*60*1000
|
||||||
#define LOG_FILES_MAX_NUM 30
|
#define LOG_FILES_MAX_NUM 30
|
||||||
@@ -716,18 +711,6 @@ private:
|
|||||||
boost::optional<Semver> m_last_config_version;
|
boost::optional<Semver> m_last_config_version;
|
||||||
bool m_config_corrupted { false };
|
bool m_config_corrupted { false };
|
||||||
std::string m_open_method;
|
std::string m_open_method;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
void RegisterMacPowerCallBack();
|
|
||||||
void UnRegisterMacPowerCallBack();
|
|
||||||
static void MacPowerCallBack(void* refcon, io_service_t service, natural_t messageType, void * messageArgument);
|
|
||||||
|
|
||||||
bool m_mac_powercallback_registered = false;
|
|
||||||
void* m_mac_refcon;
|
|
||||||
IONotificationPortRef m_mac_io_notify_port;
|
|
||||||
io_object_t m_mac_io_obj;
|
|
||||||
io_service_t m_mac_io_service;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_APP(GUI_App)
|
DECLARE_APP(GUI_App)
|
||||||
|
|||||||
Reference in New Issue
Block a user