From: Daniel Carl Date: Fri, 14 Jun 2013 08:13:06 +0000 (+0200) Subject: Fixed no more working counts for key commands. X-Git-Url: https://git.owens.tech/assets/static/git.owens.tech/assets/static/git.owens.tech/git?a=commitdiff_plain;h=daed9379a2b8852802e21f50699fabf48e248f1f;p=vimb.git Fixed no more working counts for key commands. Another way to avoid access to destroyed widget. Don't destroy the widgets explicitly, this makes the gtk for us. --- diff --git a/src/command.c b/src/command.c index 714aa02..23cb4cb 100644 --- a/src/command.c +++ b/src/command.c @@ -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; } diff --git a/src/keybind.c b/src/keybind.c index b532e91..5de85e1 100644 --- a/src/keybind.c +++ b/src/keybind.c @@ -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; } diff --git a/src/main.c b/src/main.c index 8853d8b..193557e 100644 --- a/src/main.c +++ b/src/main.c @@ -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) diff --git a/src/main.h b/src/main.h index c84469f..904b7c8 100644 --- a/src/main.h +++ b/src/main.h @@ -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 */