mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
Terminal: Fix trying to free() a stack variable
GWindow::~GWindow() deletes the main widget, assuming it was allocated with new; this is what all other applications do, so heap-allocate the terminal widget as well even though it's not necessary in this case.
This commit is contained in:
parent
2ad963d261
commit
9de48cd81a
1 changed files with 10 additions and 10 deletions
|
@ -150,27 +150,27 @@ int main(int argc, char** argv)
|
||||||
window->set_double_buffering_enabled(false);
|
window->set_double_buffering_enabled(false);
|
||||||
|
|
||||||
RefPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
|
RefPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
|
||||||
Terminal terminal(ptm_fd, config);
|
auto* terminal = new Terminal(ptm_fd, config);
|
||||||
window->set_has_alpha_channel(true);
|
window->set_has_alpha_channel(true);
|
||||||
window->set_main_widget(&terminal);
|
window->set_main_widget(terminal);
|
||||||
window->move_to(300, 300);
|
window->move_to(300, 300);
|
||||||
terminal.apply_size_increments_to_window(*window);
|
terminal->apply_size_increments_to_window(*window);
|
||||||
window->show();
|
window->show();
|
||||||
window->set_icon(load_png("/res/icons/16x16/app-terminal.png"));
|
window->set_icon(load_png("/res/icons/16x16/app-terminal.png"));
|
||||||
terminal.set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false));
|
terminal->set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false));
|
||||||
|
|
||||||
WeakPtr<GWindow> settings_window;
|
WeakPtr<GWindow> settings_window;
|
||||||
|
|
||||||
auto new_opacity = config->read_num_entry("Window", "Opacity", 255);
|
auto new_opacity = config->read_num_entry("Window", "Opacity", 255);
|
||||||
terminal.set_opacity(new_opacity);
|
terminal->set_opacity(new_opacity);
|
||||||
|
|
||||||
auto menubar = make<GMenuBar>();
|
auto menubar = make<GMenuBar>();
|
||||||
|
|
||||||
auto app_menu = make<GMenu>("Terminal");
|
auto app_menu = make<GMenu>("Terminal");
|
||||||
app_menu->add_action(GAction::create("Settings...",
|
app_menu->add_action(GAction::create("Settings...",
|
||||||
[&settings_window, &terminal, &config](const GAction&) {
|
[&settings_window, terminal, &config](const GAction&) {
|
||||||
if (!settings_window)
|
if (!settings_window)
|
||||||
settings_window = create_settings_window(terminal, config)->make_weak_ptr();
|
settings_window = create_settings_window(*terminal, config)->make_weak_ptr();
|
||||||
settings_window->show();
|
settings_window->show();
|
||||||
settings_window->move_to_front();
|
settings_window->move_to_front();
|
||||||
}));
|
}));
|
||||||
|
@ -183,13 +183,13 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto font_menu = make<GMenu>("Font");
|
auto font_menu = make<GMenu>("Font");
|
||||||
GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
|
GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
|
||||||
font_menu->add_action(GAction::create(font_name, [&terminal, &config](const GAction& action) {
|
font_menu->add_action(GAction::create(font_name, [terminal, &config](const GAction& action) {
|
||||||
terminal.set_font(GFontDatabase::the().get_by_name(action.text()));
|
terminal->set_font(GFontDatabase::the().get_by_name(action.text()));
|
||||||
auto metadata = GFontDatabase::the().get_metadata_by_name(action.text());
|
auto metadata = GFontDatabase::the().get_metadata_by_name(action.text());
|
||||||
ASSERT(metadata.has_value());
|
ASSERT(metadata.has_value());
|
||||||
config->write_entry("Text", "Font", metadata.value().path);
|
config->write_entry("Text", "Font", metadata.value().path);
|
||||||
config->sync();
|
config->sync();
|
||||||
terminal.force_repaint();
|
terminal->force_repaint();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
menubar->add_menu(move(font_menu));
|
menubar->add_menu(move(font_menu));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue