[gnote] Fix crash when using tray icon



commit f2bf84fdc2e5d73fdb32558cf6e936351cfd563e
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Mon Jun 17 21:24:00 2013 +0300

    Fix crash when using tray icon
    
    If main window is not opened, segfault can happen when exiting Gnote.

 src/recentchanges.cpp |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index f35f73e..c5c6d27 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -330,9 +330,13 @@ namespace gnote {
 
   void NoteRecentChanges::on_close_window()
   {
-    Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_boolean(
-        Preferences::MAIN_WINDOW_MAXIMIZED,
-        get_window()->get_state() & Gdk::WINDOW_STATE_MAXIMIZED);
+    Glib::RefPtr<Gdk::Window> win = get_window();
+    // background window (for tray to work) might not have GDK window
+    if(win) {
+      Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_boolean(
+          Preferences::MAIN_WINDOW_MAXIMIZED,
+          win->get_state() & Gdk::WINDOW_STATE_MAXIMIZED);
+    }
     std::vector<Gtk::Widget*> current = m_embed_box.get_children();
     for(std::vector<Gtk::Widget*>::iterator iter = current.begin();
         iter != current.end(); ++iter) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]