summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2019-08-06 12:42:13 +0300
committerAndreas Kling <awesomekling@gmail.com>2019-08-06 11:59:14 +0200
commit9de48cd81a2058e0f6d804e8c6a40c9b66b771fc (patch)
tree9134e332912beb0275dbb91b968b8ab11686283e
parent2ad963d261abf8452a5dea959c0366aaee6fa6c5 (diff)
downloadserenity-9de48cd81a2058e0f6d804e8c6a40c9b66b771fc.zip
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.
-rw-r--r--Applications/Terminal/main.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp
index 81b492e144..37e19c0eaf 100644
--- a/Applications/Terminal/main.cpp
+++ b/Applications/Terminal/main.cpp
@@ -150,27 +150,27 @@ int main(int argc, char** argv)
window->set_double_buffering_enabled(false);
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_main_widget(&terminal);
+ window->set_main_widget(terminal);
window->move_to(300, 300);
- terminal.apply_size_increments_to_window(*window);
+ terminal->apply_size_increments_to_window(*window);
window->show();
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;
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 app_menu = make<GMenu>("Terminal");
app_menu->add_action(GAction::create("Settings...",
- [&settings_window, &terminal, &config](const GAction&) {
+ [&settings_window, terminal, &config](const GAction&) {
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->move_to_front();
}));
@@ -183,13 +183,13 @@ int main(int argc, char** argv)
auto font_menu = make<GMenu>("Font");
GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
- font_menu->add_action(GAction::create(font_name, [&terminal, &config](const GAction& action) {
- terminal.set_font(GFontDatabase::the().get_by_name(action.text()));
+ font_menu->add_action(GAction::create(font_name, [terminal, &config](const GAction& action) {
+ terminal->set_font(GFontDatabase::the().get_by_name(action.text()));
auto metadata = GFontDatabase::the().get_metadata_by_name(action.text());
ASSERT(metadata.has_value());
config->write_entry("Text", "Font", metadata.value().path);
config->sync();
- terminal.force_repaint();
+ terminal->force_repaint();
}));
});
menubar->add_menu(move(font_menu));