Fixed no more working counts for key commands.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 14 Jun 2013 08:13:06 +0000 (10:13 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 14 Jun 2013 10:51:29 +0000 (12:51 +0200)
Another way to avoid access to destroyed widget. Don't destroy the widgets
explicitly, this makes the gtk for us.

src/command.c
src/keybind.c
src/main.c
src/main.h

index 714aa02..23cb4cb 100644 (file)
@@ -317,8 +317,7 @@ gboolean command_input(const Arg *arg)
 
 gboolean command_close(const Arg *arg)
 {
-    gtk_widget_destroy(GTK_WIDGET(vb.gui.window));
-
+    vb_quit();
     return true;
 }
 
index b532e91..5de85e1 100644 (file)
@@ -275,12 +275,12 @@ static gboolean keypress_cb(WebKitWebView *webview, GdkEventKey *event)
     GSList *link = find(CLEAN_MODE(vb.state.mode), vb.state.modkey, state, keyval);
 
     if (link) {
-        vb.state.modkey = vb.state.count = 0;
-        vb_update_statusbar();
-
         Keybind *keybind = (Keybind*)link->data;
         keybind->func(&keybind->arg);
 
+        vb.state.modkey = vb.state.count = 0;
+        vb_update_statusbar();
+
         return true;
     }
 
index 8853d8b..193557e 100644 (file)
@@ -355,6 +355,31 @@ VbInputType vb_get_input_parts(const char* input, const char **prefix, const cha
     return VB_INPUT_UNKNOWN;
 }
 
+void vb_quit(void)
+{
+    const char *uri = GET_URI();
+    /* write last URL into file for recreation */
+    if (uri) {
+        g_file_set_contents(vb.files[FILES_CLOSED], uri, -1, NULL);
+    }
+
+    completion_clean();
+
+    webkit_web_view_stop_loading(vb.gui.webview);
+
+    command_cleanup();
+    setting_cleanup();
+    keybind_cleanup();
+    shortcut_cleanup();
+    history_cleanup();
+
+    for (int i = 0; i < FILES_LAST; i++) {
+        g_free(vb.files[i]);
+    }
+
+    gtk_main_quit();
+}
+
 static gboolean hide_message()
 {
     inputbox_print(false, VB_MSG_NORMAL, false, "");
@@ -445,31 +470,7 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
 
 static void destroy_window_cb(GtkWidget *widget)
 {
-    const char *uri = GET_URI();
-    /* write last URL into file for recreation */
-    if (uri) {
-        g_file_set_contents(vb.files[FILES_CLOSED], uri, -1, NULL);
-    }
-
-    completion_clean();
-
-    webkit_web_view_stop_loading(vb.gui.webview);
-    gtk_widget_destroy(GTK_WIDGET(vb.gui.webview));
-    gtk_widget_destroy(GTK_WIDGET(vb.gui.scroll));
-    gtk_widget_destroy(GTK_WIDGET(vb.gui.box));
-    gtk_widget_destroy(GTK_WIDGET(vb.gui.window));
-
-    command_cleanup();
-    setting_cleanup();
-    keybind_cleanup();
-    shortcut_cleanup();
-    history_cleanup();
-
-    for (int i = 0; i < FILES_LAST; i++) {
-        g_free(vb.files[i]);
-    }
-
-    gtk_main_quit();
+    vb_quit();
 }
 
 static void inputbox_activate_cb(GtkEntry *entry)
index c84469f..904b7c8 100644 (file)
@@ -324,5 +324,6 @@ void vb_update_input_style(void);
 void vb_update_urlbar(const char *uri);
 VbInputType vb_get_input_parts(const char* input, const char **prefix, const char **clean);
 gboolean vb_download(WebKitWebView *view, WebKitDownload *download, const char *path);
+void vb_quit(void);
 
 #endif /* end of include guard: _MAIN_H */