diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2017-07-28 23:31:51 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2017-07-28 23:31:51 +0200 |
| commit | 405ec32adab103297ac167ac5eda3f1750ae54d7 (patch) | |
| tree | a6848d0ccf4c5ca3f5ddc063b1c88c2b8dc7eaa7 /src/gui_gtk.cc | |
| parent | 00bb1dc48e8b4f0e607adc1d60b456cac4fbd1e1 (diff) | |
Gtk: Fix crash when GtkGuiMain::set_package(null) was called
Diffstat (limited to 'src/gui_gtk.cc')
| -rw-r--r-- | src/gui_gtk.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui_gtk.cc b/src/gui_gtk.cc index 062ac4c..af67921 100644 --- a/src/gui_gtk.cc +++ b/src/gui_gtk.cc @@ -1907,8 +1907,14 @@ void GtkGuiMain::set_package(std::unique_ptr<AttributedText>&& text) { package_.swap(text); auto wnd = reinterpret_cast<MainAppWindow*>(window()); if (wnd) { - gtk_text_view_set_buffer(GTK_TEXT_VIEW(wnd->bottom_), - static_cast<GtkAttributedText*>(package_.get())->buffer()); + GtkTextBuffer* buf; + if (package_) { + buf = static_cast<GtkAttributedText*>(package_.get())->buffer(); + } else { + buf = gtk_text_buffer_new(NULL); + } + gtk_text_view_set_buffer(GTK_TEXT_VIEW(wnd->bottom_), buf); + if (!package_) g_object_unref(buf); } } |
