Skip to content

Commit

Permalink
fix: crash using powerMonitor before ready event (#40924)
Browse files Browse the repository at this point in the history
* fix: crash using powerMonitor before ready event

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* refactor: continue using DBusBluezManagerWrapperLinux

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Jan 10, 2024
1 parent 0862529 commit 337684f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion shell/browser/electron_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
#include "base/environment.h"
#include "chrome/browser/ui/views/dark_mode_manager_linux.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/dbus_bluez_manager_wrapper_linux.h"
#include "electron/electron_gtk_stubs.h"
#include "ui/base/cursor/cursor_factory.h"
Expand Down Expand Up @@ -508,7 +509,8 @@ void ElectronBrowserMainParts::PostCreateMainMessageLoop() {
ui::OzonePlatform::GetInstance()->PostCreateMainMessageLoop(
std::move(shutdown_cb),
content::GetUIThreadTaskRunner({content::BrowserTaskType::kUserInput}));
bluez::DBusBluezManagerWrapperLinux::Initialize();
if (!bluez::BluezDBusManager::IsInitialized())
bluez::DBusBluezManagerWrapperLinux::Initialize();

// Set up crypt config. This needs to be done before anything starts the
// network service, as the raw encryption key needs to be shared with the
Expand Down
5 changes: 5 additions & 0 deletions shell/browser/lib/power_observer_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"
#include "device/bluetooth/dbus/dbus_bluez_manager_wrapper_linux.h"

namespace {

Expand All @@ -34,6 +36,9 @@ PowerObserverLinux::PowerObserverLinux(
base::PowerSuspendObserver* suspend_observer)
: suspend_observer_(suspend_observer),
lock_owner_name_(GetExecutableBaseName()) {
if (!bluez::BluezDBusManager::IsInitialized())
bluez::DBusBluezManagerWrapperLinux::Initialize();

auto* bus = bluez::BluezDBusThreadManager::Get()->GetSystemBus();
if (!bus) {
LOG(WARNING) << "Failed to get system bus connection";
Expand Down

0 comments on commit 337684f

Please sign in to comment.