Skip to content

Commit 85bc09a

Browse files
committed
Fix crash caused by in correct config file
1 parent 3afcd30 commit 85bc09a

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/gui_interface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class GuiInterface {
7575
int channelWidthMode,
7676
const std::string &keyPath,
7777
const std::string &codec) {
78+
// For clearing obsolete entries.
79+
toolkit::mINI::Instance().clear();
80+
7881
// Save config.
7982
toolkit::mINI::Instance()[CONFIG_DEVICE] = vidPid;
8083
toolkit::mINI::Instance()[CONFIG_CHANNEL] = channel;

src/main.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ class MyControlPanel : public Flint::Panel {
421421
hbox_container->add_child(label);
422422

423423
channel_button_ = std::make_shared<Flint::MenuButton>();
424-
channel_button_->set_text(std::to_string(channel));
425424
channel_button_->container_sizing.expand_h = true;
426425
channel_button_->container_sizing.flag_h = Flint::ContainerSizingFlag::Fill;
427426
hbox_container->add_child(channel_button_);
@@ -432,9 +431,15 @@ class MyControlPanel : public Flint::Panel {
432431
auto callback = [this](uint32_t) { channel = std::stoi(channel_button_->get_selected_item_text()); };
433432
channel_button_->connect_signal("item_selected", callback);
434433

434+
uint32_t selected = 0;
435435
for (auto c : CHANNELS) {
436436
channel_menu.lock()->create_item(std::to_string(c));
437+
if (std::to_string(channel) == std::to_string(c)) {
438+
selected = channel_menu.lock()->get_item_count() - 1;
439+
}
437440
}
441+
442+
channel_button_->select_item(selected);
438443
}
439444
}
440445

@@ -449,18 +454,28 @@ class MyControlPanel : public Flint::Panel {
449454
channel_width_button_ = std::make_shared<Flint::MenuButton>();
450455
channel_width_button_->container_sizing.expand_h = true;
451456
channel_width_button_->container_sizing.flag_h = Flint::ContainerSizingFlag::Fill;
452-
channel_width_button_->set_text(CHANNEL_WIDTHS[channelWidthMode]);
453457
hbox_container->add_child(channel_width_button_);
454458

455459
{
456460
auto channel_width_menu = channel_width_button_->get_popup_menu();
457461

458-
auto callback = [this](uint32_t) { channelWidthMode = channel_button_->get_selected_item_index(); };
462+
auto callback = [this](uint32_t) {
463+
auto selected = channel_width_button_->get_selected_item_index();
464+
if (selected.has_value()) {
465+
channelWidthMode = selected.value();
466+
}
467+
};
459468
channel_width_button_->connect_signal("item_selected", callback);
460469

470+
uint32_t selected = 0;
461471
for (auto width : CHANNEL_WIDTHS) {
462472
channel_width_menu.lock()->create_item(width);
473+
int current_index = channel_width_menu.lock()->get_item_count() - 1;
474+
if (channelWidthMode == current_index) {
475+
selected = current_index;
476+
}
463477
}
478+
channel_width_button_->select_item(selected);
464479
}
465480
}
466481

@@ -529,8 +544,12 @@ class MyControlPanel : public Flint::Panel {
529544

530545
int main() {
531546
Flint::App app({1280, 720});
547+
Flint::Logger::set_module_level("Flint", Flint::Logger::Level::Debug);
532548
app.set_window_title("Aviateur - OpenIPC FPV Ground Station");
533549

550+
// Redirect standard ouput to a file
551+
freopen("last_run_log.txt", "w", stdout);
552+
534553
auto hbox_container = std::make_shared<Flint::HBoxContainer>();
535554
hbox_container->set_separation(2);
536555
hbox_container->set_anchor_flag(Flint::AnchorFlag::FullRect);

0 commit comments

Comments
 (0)