Skip to content

Commit 5dbd429

Browse files
committed
Tidy up
1 parent 175c6cc commit 5dbd429

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ OpenIPC FPV ground station for Linux/Windows/macOS. Forked from [fpv4win](https:
3333

3434
1. (Optional) Go to `/lib/udev/rules.d`, create a new file named `80-my8812au.rules` and add
3535
`SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="8812", MODE="0666"` in it.
36-
2. (Optional) Call `sudo udevadm control --reload-rules`, then reboot (this is definitely required).
37-
3. Run Aviateur (if you skip step 1 & 2, root privileges are needed to access the adapter).
36+
Call `sudo udevadm control --reload-rules`, then reboot (this is definitely required).
37+
2. Run Aviateur (if you skip step 1 & 2, root privileges are needed to access the adapter).
3838

3939
### How to run on macOS
4040

src/main.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ int main() {
1212
GuiInterface::Instance().init();
1313
GuiInterface::Instance().PutLog(LogLevel::Info, "App started");
1414

15-
auto app =
16-
new revector::App({1080, 480}, GuiInterface::Instance().dark_mode_, GuiInterface::Instance().use_vulkan_);
15+
auto app = std::make_shared<revector::App>(revector::Vec2I{1280, 720},
16+
GuiInterface::Instance().dark_mode_,
17+
GuiInterface::Instance().use_vulkan_);
1718
app->set_window_title("Aviateur - OpenIPC FPV Ground Station");
1819

19-
GuiInterface::Instance().PutLog(LogLevel::Info, "revector app created");
20-
2120
revector::TranslationServer::get_singleton()->load_translations(revector::get_asset_dir("translations.csv"));
2221

2322
// Initialize the default libusb context.
@@ -41,14 +40,14 @@ int main() {
4140
std::weak_ptr control_panel_weak = control_panel;
4241
std::weak_ptr player_rect_weak = player_rect;
4342

44-
auto onWifiStop = [control_panel_weak, player_rect_weak] {
43+
auto on_wifi_stopped = [control_panel_weak, player_rect_weak] {
4544
if (!control_panel_weak.expired() && !player_rect_weak.expired()) {
4645
player_rect_weak.lock()->stop_playing();
4746
player_rect_weak.lock()->show_red_tip(FTR("wi-fi stopped msg"));
4847
control_panel_weak.lock()->update_adapter_start_button_looking(true);
4948
}
5049
};
51-
GuiInterface::Instance().wifiStopCallbacks.emplace_back(onWifiStop);
50+
GuiInterface::Instance().wifiStopCallbacks.emplace_back(on_wifi_stopped);
5251

5352
{
5453
player_rect->top_control_container = std::make_shared<revector::HBoxContainer>();
@@ -59,24 +58,25 @@ int main() {
5958
player_rect->top_control_container->add_child(player_rect->fullscreen_button_);
6059
player_rect->fullscreen_button_->set_text(FTR("fullscreen") + " (F11)");
6160

62-
auto callback = [app, control_panel_weak](bool toggled) {
63-
if (!control_panel_weak.expired()) {
64-
app->set_fullscreen(toggled);
61+
std::weak_ptr app_weak = app;
62+
auto on_fullscreen_toggled = [app_weak](bool toggled) {
63+
if (!app_weak.expired()) {
64+
app_weak.lock()->set_fullscreen(toggled);
6565
}
6666
};
67-
player_rect->fullscreen_button_->connect_signal("toggled", callback);
67+
player_rect->fullscreen_button_->connect_signal("toggled", on_fullscreen_toggled);
6868

6969
auto control_panel_button = std::make_shared<revector::CheckButton>();
7070
player_rect->top_control_container->add_child(control_panel_button);
7171
control_panel_button->set_text(FTR("control panel"));
7272
control_panel_button->set_toggled(true);
7373

74-
auto callback2 = [control_panel_weak](bool toggled) {
74+
auto on_control_panel_toggled = [control_panel_weak](bool toggled) {
7575
if (!control_panel_weak.expired()) {
7676
control_panel_weak.lock()->set_visibility(toggled);
7777
}
7878
};
79-
control_panel_button->connect_signal("toggled", callback2);
79+
control_panel_button->connect_signal("toggled", on_control_panel_toggled);
8080
}
8181
}
8282

@@ -86,9 +86,7 @@ int main() {
8686

8787
GuiInterface::SaveConfig();
8888

89-
// Quit app.
90-
delete app;
91-
app = nullptr;
89+
app.reset();
9290

9391
libusb_exit(nullptr);
9492

0 commit comments

Comments
 (0)