summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-07-28 23:31:51 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-28 23:31:51 +0200
commit405ec32adab103297ac167ac5eda3f1750ae54d7 (patch)
treea6848d0ccf4c5ca3f5ddc063b1c88c2b8dc7eaa7
parent00bb1dc48e8b4f0e607adc1d60b456cac4fbd1e1 (diff)
Gtk: Fix crash when GtkGuiMain::set_package(null) was called
-rw-r--r--src/gui_gtk.cc10
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);
}
}