Made _moo_icon_view_selected_foreach() robust against selection changes during iterating

master
Yevgen Muntyan 2007-01-26 10:01:54 -06:00
parent 9339da4221
commit 7ae13cf245
6 changed files with 43 additions and 51 deletions

View File

@ -10,6 +10,7 @@
<configure> <configure>
<args>--enable-debug=full --enable-all-warnings --enable-libmoo --with-mooterm</args> <args>--enable-debug=full --enable-all-warnings --enable-libmoo --with-mooterm</args>
<vars> <vars>
<var name="CC">gcc-3.4</var>
<var name="CFLAGS">-g</var> <var name="CFLAGS">-g</var>
</vars> </vars>
</configure> </configure>
@ -31,12 +32,13 @@
<configure> <configure>
<args>--enable-all-warnings</args> <args>--enable-all-warnings</args>
<vars> <vars>
<var name="CC">gcc-3.4</var>
<var name="CFLAGS">-g -O2</var> <var name="CFLAGS">-g -O2</var>
</vars> </vars>
</configure> </configure>
</optimized> </optimized>
</configurations> </configurations>
<file_selector_dir>/home/muntyan/projects/moo/moo/mooapp/smclient/</file_selector_dir> <file_selector_dir>/home/muntyan/projects/moo/moo/mooedit/gtksourceview/upstream/</file_selector_dir>
<run> <run>
<args>--g-fatal-warnings --new-app --mode=project</args> <args>--g-fatal-warnings --new-app --mode=project</args>
<exe>medit/medit</exe> <exe>medit/medit</exe>

View File

@ -6,7 +6,6 @@
Editor Editor
======== ========
1. Make messages in xml parser include file name.
2. File saving: permissions, backups, symlinks. 2. File saving: permissions, backups, symlinks.
3. moo_editor_save_tmp(), moo_editor_save_fake() ? 3. moo_editor_save_tmp(), moo_editor_save_fake() ?
@ -17,18 +16,3 @@ Terminal
0. FIX IT! 0. FIX IT!
1. Think about profiles, can they help? 1. Think about profiles, can they help?
2. Terminal settings. 2. Terminal settings.
App
========
Misc
========
1. Make MooNotebook subclass GtkNotebook so stupid themes don't break.
Bugs
========
1. HistoryList - make it load when needed.

View File

@ -17,7 +17,9 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif
#include "eggsmclient-private.h" #include "eggsmclient-private.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
@ -43,7 +45,7 @@ struct _EggSMClientWin32 {
char *state_dir; char *state_dir;
#endif #endif
gboolean in_filter; guint in_filter;
gboolean will_quit; gboolean will_quit;
gboolean will_quit_set; gboolean will_quit_set;
}; };
@ -199,18 +201,35 @@ sm_client_win32_end_session (EggSMClient *client,
static gboolean static gboolean
will_quit (EggSMClientWin32 *win32) will_quit (EggSMClientWin32 *win32)
{ {
gboolean emit_quit_requested;
/* Will this really work? Or do we need to do something kinky like /* Will this really work? Or do we need to do something kinky like
* arrange to have at least one WM_QUERYENDSESSION message delivered * arrange to have at least one WM_QUERYENDSESSION message delivered
* to another thread and then have that thread wait for the main * to another thread and then have that thread wait for the main
* thread to process the quit_requested signal asynchronously before * thread to process the quit_requested signal asynchronously before
* returning? FIXME * returning? FIXME
*/ */
win32->will_quit_set = FALSE;
egg_sm_client_quit_requested ((EggSMClient *)win32); win32->in_filter++;
g_message ("hi there");
if (win32->in_filter == 1)
{
win32->will_quit_set = FALSE;
g_message ("calling gtk_dialog_run in will_quit");
gtk_dialog_run (gtk_dialog_new ());
g_message ("done");
egg_sm_client_quit_requested ((EggSMClient *)win32);
}
while (!win32->will_quit_set) while (!win32->will_quit_set)
gtk_main_iteration (); gtk_main_iteration ();
g_assert (win32->in_filter > 0);
if (--win32->in_filter == 0)
win32->will_quit_set = FALSE;
return win32->will_quit; return win32->will_quit;
} }
@ -224,35 +243,26 @@ egg_sm_client_win32_filter (GdkXEvent *xevent,
MSG *msg = (MSG *)xevent; MSG *msg = (MSG *)xevent;
GdkFilterReturn retval; GdkFilterReturn retval;
if (win32->in_filter)
{
g_message ("win32->in_filter");
return GDK_FILTER_CONTINUE;
}
/* FIXME: I think these messages are delivered per-window, not /* FIXME: I think these messages are delivered per-window, not
* per-app, so we need to make sure we only act on them once. (Does * per-app, so we need to make sure we only act on them once. (Does
* the win32 backend have client leader windows like x11?) * the win32 backend have client leader windows like x11?)
*/ */
win32->in_filter = TRUE;
switch (msg->message) switch (msg->message)
{ {
case WM_QUERYENDSESSION: case WM_QUERYENDSESSION:
/* If we return GDK_FILTER_CONTINUE, the event will eventually return will_quit (win32) ? GDK_FILTER_CONTINUE : GDK_FILTER_REMOVE;
* get passed on to DefWindowProc, which will return TRUE,
* allowing the logout to continue. If we return
* GDK_FILTER_REMOVE, then inner_window_procedure will return
* its default value, 0, aka FALSE, causing the logout to be
* aborted.
*/
retval = will_quit (win32) ? GDK_FILTER_CONTINUE : GDK_FILTER_REMOVE;
break;
case WM_ENDSESSION: case WM_ENDSESSION:
if (msg->wParam) if (msg->wParam)
{ {
/* Make sure we don't spin main loop in will_quit() */
if (win32->in_filter)
{
win32->will_quit_set = TRUE;
win32->will_quit = TRUE;
}
/* The session is ending */ /* The session is ending */
#ifdef VISTA #ifdef VISTA
if ((msg->lParam & ENDSESSION_CLOSEAPP) && win32->registered) if ((msg->lParam & ENDSESSION_CLOSEAPP) && win32->registered)
@ -276,16 +286,11 @@ egg_sm_client_win32_filter (GdkXEvent *xevent,
* to return, although the docs don't say what happens if you return * to return, although the docs don't say what happens if you return
* any other value. * any other value.
*/ */
retval = GDK_FILTER_REMOVE; return GDK_FILTER_REMOVE;
break;
default: default:
retval = GDK_FILTER_CONTINUE; return GDK_FILTER_CONTINUE;
break;
} }
win32->in_filter = FALSE;
return retval;
} }
#ifdef VISTA #ifdef VISTA

View File

@ -1175,10 +1175,9 @@ process_ice_messages (IceConn ice_conn)
case IceProcessMessagesConnectionClosed: case IceProcessMessagesConnectionClosed:
return FALSE; return FALSE;
default:
g_assert_not_reached ();
} }
g_return_val_if_reached (FALSE);
} }
static gboolean static gboolean

View File

@ -17,7 +17,9 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -2574,7 +2574,7 @@ _moo_icon_view_selected_foreach (MooIconView *view,
gpointer data) gpointer data)
{ {
Selection *selection; Selection *selection;
GSList *link, *selected; GSList *l, *selected;
GtkTreePath *path; GtkTreePath *path;
GtkTreeIter iter; GtkTreeIter iter;
@ -2585,15 +2585,15 @@ _moo_icon_view_selected_foreach (MooIconView *view,
selection = view->priv->selection; selection = view->priv->selection;
for (link = selection->selected, selected = NULL; link != NULL; link = link->next) for (l = selection->selected, selected = NULL; l != NULL; l = l->next)
selected = g_slist_prepend (selected, gtk_tree_row_reference_copy (link->data)); selected = g_slist_prepend (selected, gtk_tree_row_reference_copy (l->data));
selected = g_slist_reverse (selected); selected = g_slist_reverse (selected);
while (selected) while (selected)
{ {
if (gtk_tree_row_reference_valid (selected->data)) if (gtk_tree_row_reference_valid (selected->data))
{ {
path = gtk_tree_row_reference_get_path (link->data); path = gtk_tree_row_reference_get_path (selected->data);
gtk_tree_model_get_iter (view->priv->model, &iter, path); gtk_tree_model_get_iter (view->priv->model, &iter, path);
func (view->priv->model, path, &iter, data); func (view->priv->model, path, &iter, data);
gtk_tree_path_free (path); gtk_tree_path_free (path);