reviewed by: John Sullivan <sullivan@eazel.com>

* libnautilus/nautilus-bonobo-workarounds.c:
	(nautilus_bonobo_object_force_destroy): Add new version that is
	not vulnerable to the problem of an unref coming in from the other
	process during the destroy phase. This version relies on Bonobo
	internals, so it's a truly evil bit of code, and I should be
	severely punished for even thinking of writing it.
	(nautilus_bonobo_object_force_destroy_at_idle): Added some more
	checks that I thought would help me in debugging.

	* src/nautilus-shell-ui.xml: Improve wording of tooltip for the Up
	command.

	* components/notes/nautilus-notes.c: Some code cleanup.

	* src/file-manager/fm-directory-view.c: Fixed a typo.
This commit is contained in:
Darin Adler 2001-04-03 20:59:03 +00:00
parent 28b5c6daf7
commit f7ea58e25b
5 changed files with 141 additions and 42 deletions

View file

@ -1,3 +1,23 @@
2001-04-03 Darin Adler <darin@eazel.com>
reviewed by: John Sullivan <sullivan@eazel.com>
* libnautilus/nautilus-bonobo-workarounds.c:
(nautilus_bonobo_object_force_destroy): Add new version that is
not vulnerable to the problem of an unref coming in from the other
process during the destroy phase. This version relies on Bonobo
internals, so it's a truly evil bit of code, and I should be
severely punished for even thinking of writing it.
(nautilus_bonobo_object_force_destroy_at_idle): Added some more
checks that I thought would help me in debugging.
* src/nautilus-shell-ui.xml: Improve wording of tooltip for the Up
command.
* components/notes/nautilus-notes.c: Some code cleanup.
* src/file-manager/fm-directory-view.c: Fixed a typo.
2001-04-03 John Sullivan <sullivan@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>

View file

@ -3,7 +3,7 @@
/*
* Nautilus
*
* Copyright (C) 2000 Eazel, Inc.
* Copyright (C) 2000, 2001 Eazel, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@ -75,34 +75,33 @@ static int notes_object_count = 0;
/* property bag getting and setting routines */
enum {
TAB_IMAGE,
} MyArgs;
};
static void
get_bonobo_properties (BonoboPropertyBag *bag,
BonoboArg *arg,
guint arg_id,
CORBA_Environment *ev,
gpointer user_data)
gpointer callback_data)
{
char *indicator_image;
Notes *notes;
notes = (Notes*) user_data;
notes = (Notes *) callback_data;
switch (arg_id) {
case TAB_IMAGE:
{
/* if there is a note, return the name of the indicator image,
otherwise, return NULL */
indicator_image = notes_get_indicator_image (notes->previous_saved_text);
BONOBO_ARG_SET_STRING (arg, indicator_image);
g_free (indicator_image);
break;
}
default:
g_warning ("Unhandled arg %d", arg_id);
break;
case TAB_IMAGE: {
/* if there is a note, return the name of the indicator image,
otherwise, return NULL */
indicator_image = notes_get_indicator_image (notes->previous_saved_text);
BONOBO_ARG_SET_STRING (arg, indicator_image);
g_free (indicator_image);
break;
}
default:
g_warning ("Unhandled arg %d", arg_id);
break;
}
}
@ -111,9 +110,9 @@ set_bonobo_properties (BonoboPropertyBag *bag,
const BonoboArg *arg,
guint arg_id,
CORBA_Environment *ev,
gpointer user_data)
gpointer callback_data)
{
g_warning ("Cant set note property %d", arg_id);
g_warning ("Can't set note property %u", arg_id);
}
static gboolean
@ -123,8 +122,9 @@ schedule_save_callback (gpointer data)
notes = data;
/* Zero out save_timeout_id so no one will try to cancel our in-progress timeout callback.
*/
/* Zero out save_timeout_id so no one will try to cancel our
* in-progress timeout callback.
*/
notes->save_timeout_id = 0;
notes_save_metainfo (notes);
@ -165,7 +165,6 @@ load_note_text_from_metadata (NautilusFile *file,
* metadata has actually changed.
*/
if (nautilus_strcmp (saved_text, notes->previous_saved_text) != 0) {
notify_listeners_if_changed (notes, saved_text);
g_free (notes->previous_saved_text);
@ -247,12 +246,13 @@ notify_listeners_if_changed (Notes *notes, char *new_notes)
tab_image_arg = bonobo_arg_new (BONOBO_ARG_STRING);
BONOBO_ARG_SET_STRING (tab_image_arg, tab_image);
bonobo_property_bag_notify_listeners (notes->property_bag, "tab_image", tab_image_arg, NULL);
bonobo_property_bag_notify_listeners (notes->property_bag,
"tab_image", tab_image_arg, NULL);
bonobo_arg_release (tab_image_arg);
g_free (tab_image);
}
}
}
/* save the metainfo corresponding to the current uri, if any, into the text field */
@ -272,13 +272,15 @@ notes_save_metainfo (Notes *notes)
gtk_signal_handler_block_by_func (GTK_OBJECT (notes->file),
load_note_text_from_metadata,
notes);
notes_text = gtk_editable_get_chars (GTK_EDITABLE (notes->note_text_field), 0 , -1);
nautilus_file_set_metadata (notes->file, NAUTILUS_METADATA_KEY_ANNOTATION, NULL, notes_text);
nautilus_file_set_metadata (notes->file,
NAUTILUS_METADATA_KEY_ANNOTATION,
NULL, notes_text);
gtk_signal_handler_unblock_by_func (GTK_OBJECT (notes->file),
load_note_text_from_metadata,
notes);
notes);
notify_listeners_if_changed (notes, notes_text);
@ -308,10 +310,11 @@ notes_load_location (NautilusView *view,
static gboolean
on_text_field_focus_out_event (GtkWidget *widget,
GdkEventFocus *event,
gpointer user_data)
gpointer callback_data)
{
Notes *notes = user_data;
Notes *notes;
notes = callback_data;
notes_save_metainfo (notes);
return FALSE;
}
@ -347,7 +350,7 @@ do_destroy (GtkObject *obj, Notes *notes)
}
}
static char*
static char *
notes_get_indicator_image (const char *notes_text)
{
if (notes_text != NULL && strlen (notes_text) > 0) {
@ -358,14 +361,15 @@ notes_get_indicator_image (const char *notes_text)
}
static BonoboObject *
make_notes_view (BonoboGenericFactory *Factory, const char *goad_id, gpointer closure)
make_notes_view (BonoboGenericFactory *Factory, const char *iid, gpointer closure)
{
GtkWidget *vbox;
Notes *notes;
NautilusBackground *background;
GdkFont *font;
g_return_val_if_fail (strcmp (goad_id, "OAFIID:nautilus_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185") == 0, NULL);
g_return_val_if_fail (strcmp (iid, "OAFIID:nautilus_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185") == 0, NULL);
notes = g_new0 (Notes, 1);
notes->uri = g_strdup ("");
@ -464,7 +468,8 @@ main(int argc, char *argv[])
g_thread_init (NULL);
gnome_vfs_init ();
registration_id = oaf_make_registration_id ("OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0", getenv ("DISPLAY"));
registration_id = oaf_make_registration_id ("OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0",
g_getenv ("DISPLAY"));
factory = bonobo_generic_factory_new_multi
(registration_id,

View file

@ -30,6 +30,26 @@
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#define RELY_ON_BONOBO_INTERNALS
#ifdef RELY_ON_BONOBO_INTERNALS
/* This is incredibly unsafe and relies on details of the Bonobo
* internals. I should be shot and killed for even thinking of doing
* this.
*/
typedef struct {
int ref_count;
GList *objs;
} StartOfBonoboAggregateObject;
typedef struct {
StartOfBonoboAggregateObject *ao;
int destroy_id;
} StartOfBonoboObjectPrivate;
#endif
/* FIXME bugzilla.eazel.com 2456: Is a hard-coded 20 seconds wait to
* detect that a remote object's process is hung acceptable? Can a
* component that is working still take 20 seconds to respond?
@ -89,6 +109,21 @@ nautilus_bonobo_stream_get_epv (void)
return &bonobo_stream_epv;
}
/* The following is the most evil function in the world. But on the
* other hand, it works and prevents us from having tons of lingering
* processes when Nautilus crashes. It's unsafe to call it if there
* are any direct references to the bonobo object, but it's OK to have
* any number of references to it through CORBA.
*/
#ifndef RELY_ON_BONOBO_INTERNALS
/* This version of the function doesn't rely on Bonobo internals as
* much as the other one does, but it gets screwed up by incoming
* unref calls while the object is being destroyed. This was actually
* happening, which is why I had to write the other version.
*/
static void
set_gone_flag (GtkObject *object,
gpointer callback_data)
@ -99,10 +134,6 @@ set_gone_flag (GtkObject *object,
*gone_flag = TRUE;
}
/* The following is the most evil function in the world. But on the
* other hand, it works and prevents us from having tons of lingering
* processes when Nautilus crashes.
*/
void
nautilus_bonobo_object_force_destroy (BonoboObject *object)
{
@ -123,6 +154,46 @@ nautilus_bonobo_object_force_destroy (BonoboObject *object)
} while (!gone);
}
#else /* RELY_ON_BONOBO_INTERNALS */
void
nautilus_bonobo_object_force_destroy (BonoboObject *object)
{
StartOfBonoboAggregateObject *aggregate;
GList *node;
GtkObject *subobject;
guint *id;
if (object == NULL) {
return;
}
g_return_if_fail (BONOBO_IS_OBJECT (object));
aggregate = ((StartOfBonoboObjectPrivate *) object->priv)->ao;
/* Do all the destroying with a normal reference count. This
* lets us live through unrefs that happen during the destroy
* process.
*/
bonobo_object_ref (object);
for (node = aggregate->objs; node != NULL; node = node->next) {
subobject = GTK_OBJECT (node->data);
id = &((StartOfBonoboObjectPrivate *) BONOBO_OBJECT (subobject)->priv)->destroy_id;
if (*id != 0) {
gtk_signal_disconnect (subobject, *id);
*id = 0;
}
gtk_object_destroy (subobject);
}
/* Now force a destroy by forcing the reference count to 1. */
aggregate->ref_count = 1;
bonobo_object_unref (object);
}
#endif /* RELY_ON_BONOBO_INTERNALS */
static gboolean
destroy_at_idle_callback (gpointer callback_data)
{
@ -160,6 +231,9 @@ nautilus_bonobo_object_force_destroy_at_idle (BonoboObject *object)
return;
}
g_return_if_fail (BONOBO_IS_OBJECT (object));
g_return_if_fail (!GTK_OBJECT_DESTROYED (object));
data = g_new (IdleDestroyData, 1);
data->object = object;
data->idle_id = gtk_idle_add

View file

@ -2,7 +2,7 @@
/* fm-directory-view.c
*
* Copyright (C) 1999, 2000 Free Software Foundaton
* Copyright (C) 1999, 2000 Free Software Foundation
* Copyright (C) 2000, 2001 Eazel, Inc.
*
* This program is free software; you can redistribute it and/or

View file

@ -27,7 +27,7 @@
<cmd name="Paste" accel="*Control*v" sensitive="0"/>
<cmd name="Clear" sensitive="0"/>
<cmd name="Up"
_tip="Go to the location that contains this one"/>
_tip="Go up to the location that contains the displayed location"/>
<cmd name="Zoom In" _label="Zoom In"
_tip="Show the contents in more detail"/>
<cmd name="Zoom Out" _label="Zoom Out"