Commit 539ae559 authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan
Browse files

Added call to CORBA_Object_duplicate(). This fixed an explosive bug.

2000-05-23  Gene Z. Ragan  <gzr@eazel.com>

	* libnautilus/nautilus-undo-context.c:
	(impl_Nautilus_Undo_Context__get_undo_manager):
	Added call to CORBA_Object_duplicate().  This
	fixed an explosive bug.

	* libnautilus/nautilus-undo-manager.c:
	* libnautilus/nautilus-undo-manager.h:
	(nautilus_undo_manager_stash_global_undo),
	(nautilus_undo_manager_get_global_undo):
	New functions to save application global instance of Nautilus_Undo_Manager

	* src/ntl-app.c: (nautilus_app_init):
	Add call to nautilus_undo_manager_stash_global_undo.

	* src/ntl-view.c:
	(nautilus_view_frame_load_client):
	Coonected Nautilus_Undo_Context interface to view frame.
parent 584b28c4
2000-05-23 Gene Z. Ragan <gzr@eazel.com>
* libnautilus/nautilus-undo-context.c:
(impl_Nautilus_Undo_Context__get_undo_manager):
Added call to CORBA_Object_duplicate(). This
fixed an explosive bug.
* libnautilus/nautilus-undo-manager.c:
* libnautilus/nautilus-undo-manager.h:
(nautilus_undo_manager_stash_global_undo),
(nautilus_undo_manager_get_global_undo):
New functions to save application global instance of Nautilus_Undo_Manager
* src/ntl-app.c: (nautilus_app_init):
Add call to nautilus_undo_manager_stash_global_undo.
* src/ntl-view.c:
(nautilus_view_frame_load_client):
Coonected Nautilus_Undo_Context interface to view frame.
2000-05-23 Ramiro Estrugo <ramiro@eazel.com>
* icons/Makefile.am:
......
......@@ -123,6 +123,8 @@ impl_Nautilus_Undo_Context__get_undo_manager (impl_POA_Nautilus_Undo_Context *se
g_assert (NAUTILUS_IS_UNDO_CONTEXT (servant->gtk_object));
context = NAUTILUS_UNDO_CONTEXT (servant->gtk_object);
CORBA_Object_duplicate (servant->gtk_object->undo_manager, ev);
return servant->gtk_object->undo_manager;
}
......
......@@ -38,6 +38,10 @@
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
/* Gloabl instance of undo manager */
Nautilus_Undo_Manager global_undo_manager;
enum {
UNDO_TRANSACTION_OCCURED,
LAST_SIGNAL
......@@ -210,7 +214,7 @@ nautilus_undo_manager_initialize (NautilusUndoManager *manager)
manager->details->queue_depth = 1;
bonobo_object_construct (BONOBO_OBJECT (manager), impl_Nautilus_Undo_Manager__create (manager, &ev));
CORBA_exception_free(&ev);
}
......@@ -705,3 +709,18 @@ nautilus_undo_set_up_bonobo_control (BonoboControl *control)
gtk_signal_connect (GTK_OBJECT (control), "set_frame",
GTK_SIGNAL_FUNC (set_up_bonobo_control), NULL);
}
void
nautilus_undo_manager_stash_global_undo (Nautilus_Undo_Manager undo_manager)
{
global_undo_manager = undo_manager;
}
Nautilus_Undo_Manager
nautilus_undo_manager_get_global_undo (void)
{
return global_undo_manager;
}
......@@ -75,4 +75,8 @@ void nautilus_share_undo_manager (GtkObject
void nautilus_undo_set_up_bonobo_control (BonoboControl *control);
Nautilus_Undo_Manager nautilus_get_undo_manager (GtkObject *start_object);
void nautilus_undo_manager_stash_global_undo (Nautilus_Undo_Manager undo_manager);
Nautilus_Undo_Manager nautilus_undo_manager_get_global_undo (void);
#endif
......@@ -123,6 +123,8 @@ impl_Nautilus_Undo_Context__get_undo_manager (impl_POA_Nautilus_Undo_Context *se
g_assert (NAUTILUS_IS_UNDO_CONTEXT (servant->gtk_object));
context = NAUTILUS_UNDO_CONTEXT (servant->gtk_object);
CORBA_Object_duplicate (servant->gtk_object->undo_manager, ev);
return servant->gtk_object->undo_manager;
}
......
......@@ -38,6 +38,10 @@
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
/* Gloabl instance of undo manager */
Nautilus_Undo_Manager global_undo_manager;
enum {
UNDO_TRANSACTION_OCCURED,
LAST_SIGNAL
......@@ -210,7 +214,7 @@ nautilus_undo_manager_initialize (NautilusUndoManager *manager)
manager->details->queue_depth = 1;
bonobo_object_construct (BONOBO_OBJECT (manager), impl_Nautilus_Undo_Manager__create (manager, &ev));
CORBA_exception_free(&ev);
}
......@@ -705,3 +709,18 @@ nautilus_undo_set_up_bonobo_control (BonoboControl *control)
gtk_signal_connect (GTK_OBJECT (control), "set_frame",
GTK_SIGNAL_FUNC (set_up_bonobo_control), NULL);
}
void
nautilus_undo_manager_stash_global_undo (Nautilus_Undo_Manager undo_manager)
{
global_undo_manager = undo_manager;
}
Nautilus_Undo_Manager
nautilus_undo_manager_get_global_undo (void)
{
return global_undo_manager;
}
......@@ -75,4 +75,8 @@ void nautilus_share_undo_manager (GtkObject
void nautilus_undo_set_up_bonobo_control (BonoboControl *control);
Nautilus_Undo_Manager nautilus_get_undo_manager (GtkObject *start_object);
void nautilus_undo_manager_stash_global_undo (Nautilus_Undo_Manager undo_manager);
Nautilus_Undo_Manager nautilus_undo_manager_get_global_undo (void);
#endif
......@@ -123,6 +123,8 @@ impl_Nautilus_Undo_Context__get_undo_manager (impl_POA_Nautilus_Undo_Context *se
g_assert (NAUTILUS_IS_UNDO_CONTEXT (servant->gtk_object));
context = NAUTILUS_UNDO_CONTEXT (servant->gtk_object);
CORBA_Object_duplicate (servant->gtk_object->undo_manager, ev);
return servant->gtk_object->undo_manager;
}
......
......@@ -38,6 +38,10 @@
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
/* Gloabl instance of undo manager */
Nautilus_Undo_Manager global_undo_manager;
enum {
UNDO_TRANSACTION_OCCURED,
LAST_SIGNAL
......@@ -210,7 +214,7 @@ nautilus_undo_manager_initialize (NautilusUndoManager *manager)
manager->details->queue_depth = 1;
bonobo_object_construct (BONOBO_OBJECT (manager), impl_Nautilus_Undo_Manager__create (manager, &ev));
CORBA_exception_free(&ev);
}
......@@ -705,3 +709,18 @@ nautilus_undo_set_up_bonobo_control (BonoboControl *control)
gtk_signal_connect (GTK_OBJECT (control), "set_frame",
GTK_SIGNAL_FUNC (set_up_bonobo_control), NULL);
}
void
nautilus_undo_manager_stash_global_undo (Nautilus_Undo_Manager undo_manager)
{
global_undo_manager = undo_manager;
}
Nautilus_Undo_Manager
nautilus_undo_manager_get_global_undo (void)
{
return global_undo_manager;
}
......@@ -75,4 +75,8 @@ void nautilus_share_undo_manager (GtkObject
void nautilus_undo_set_up_bonobo_control (BonoboControl *control);
Nautilus_Undo_Manager nautilus_get_undo_manager (GtkObject *start_object);
void nautilus_undo_manager_stash_global_undo (Nautilus_Undo_Manager undo_manager);
Nautilus_Undo_Manager nautilus_undo_manager_get_global_undo (void);
#endif
......@@ -234,8 +234,13 @@ nautilus_app_init (NautilusApp *app)
/* Init undo manager */
app->undo_manager = BONOBO_OBJECT (nautilus_undo_manager_new ());
undo_manager = bonobo_object_corba_objref (BONOBO_OBJECT (app->undo_manager));
/* Fix this */
Bonobo_Unknown_ref (undo_manager, &ev);
/* Stash a global reference to the object */
nautilus_undo_manager_stash_global_undo (undo_manager);
/* Add it to the application object*/
nautilus_attach_undo_manager ( GTK_OBJECT (app), undo_manager);
CORBA_exception_free (&ev);
......
......@@ -293,10 +293,10 @@ nautilus_view_frame_construct_arg_set(NautilusViewFrame *view)
if(view->construct_arg_count >= nca)
return;
view->construct_arg_count++;
if((view->construct_arg_count >= nca)
&& klass->view_constructed)
klass->view_constructed(view);
view->construct_arg_count++;
if((view->construct_arg_count >= nca) && klass->view_constructed) {
klass->view_constructed(view);
}
}
static void
......@@ -359,85 +359,90 @@ nautilus_view_frame_handle_client_destroy_2(GtkObject *object, CORBA_Object cobj
gboolean /* returns TRUE if successful */
nautilus_view_frame_load_client(NautilusViewFrame *view, const char *iid)
{
CORBA_Object obj;
CORBA_Object zoomable;
CORBA_Environment ev;
int i;
NautilusViewComponentType *component_types[] = {
&nautilus_view_component_type,
&bonobo_subdoc_component_type,
&bonobo_control_component_type,
NULL
};
g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE);
if (iid == NULL)
return FALSE;
CORBA_exception_init(&ev);
nautilus_view_frame_destroy_client(view);
view->client_object = bonobo_object_activate(iid, 0);
if(!view->client_object)
return FALSE;
view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev);
view->zoomable_frame = impl_Nautilus_ZoomableFrame__create(view, &ev);
/* Now figure out which type of embedded object it is: */
for(i = 0; component_types[i] && !view->component_class; i++)
{
obj = Bonobo_Unknown_query_interface(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)),
CORBA_Object obj;
CORBA_Object zoomable;
Nautilus_Undo_Manager undo_manager;
NautilusUndoContext *undo_context;
CORBA_Environment ev;
int i;
NautilusViewComponentType *component_types[] = {
&nautilus_view_component_type,
&bonobo_subdoc_component_type,
&bonobo_control_component_type,
NULL
};
g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE);
if (iid == NULL)
return FALSE;
CORBA_exception_init(&ev);
nautilus_view_frame_destroy_client(view);
view->client_object = bonobo_object_activate(iid, 0);
if(!view->client_object)
return FALSE;
view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev);
view->zoomable_frame = impl_Nautilus_ZoomableFrame__create(view, &ev);
/* Add undo manager to component */
undo_manager = nautilus_undo_manager_get_global_undo ();
g_assert (undo_manager);
undo_context = nautilus_undo_context_new (undo_manager);
bonobo_object_add_interface (BONOBO_OBJECT (view->view_frame), BONOBO_OBJECT (undo_context));
/* Now figure out which type of embedded object it is: */
for(i = 0; component_types[i] && !view->component_class; i++)
{
obj = Bonobo_Unknown_query_interface(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)),
component_types[i]->primary_repoid, &ev);
if(ev._major != CORBA_NO_EXCEPTION)
obj = CORBA_OBJECT_NIL;
if(ev._major != CORBA_NO_EXCEPTION)
obj = CORBA_OBJECT_NIL;
if(CORBA_Object_is_nil(obj, &ev))
continue;
if(CORBA_Object_is_nil(obj, &ev))
continue;
zoomable = bonobo_object_query_interface (BONOBO_OBJECT (view->client_object),
zoomable = bonobo_object_query_interface (BONOBO_OBJECT (view->client_object),
"IDL:Nautilus/Zoomable:1.0");
view->zoomable = zoomable;
view->zoomable = zoomable;
if(component_types[i]->try_load(view, obj, &ev))
view->component_class = component_types[i];
if(component_types[i]->try_load(view, obj, &ev))
view->component_class = component_types[i];
Bonobo_Unknown_unref(obj, &ev);
CORBA_Object_release(obj, &ev);
Bonobo_Unknown_unref(obj, &ev);
CORBA_Object_release(obj, &ev);
if (view->component_class)
break;
}
if (view->component_class)
break;
}
if (!view->component_class)
{
/* Nothing matched */
nautilus_view_frame_destroy_client(view);
return FALSE;
}
if (!view->component_class) {
/* Nothing matched */
nautilus_view_frame_destroy_client(view);
return FALSE;
}
view->iid = g_strdup(iid);
view->iid = g_strdup(iid);
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "destroy",
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "destroy",
GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy), view,
GTK_OBJECT(view));
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "object_gone",
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "object_gone",
GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy_2), view,
GTK_OBJECT(view));
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "system_exception",
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "system_exception",
GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy_2), view,
GTK_OBJECT(view));
gtk_container_add(GTK_CONTAINER(view), view->client_widget);
gtk_widget_show(view->client_widget);
CORBA_exception_free(&ev);
gtk_container_add(GTK_CONTAINER(view), view->client_widget);
gtk_widget_show(view->client_widget);
CORBA_exception_free(&ev);
return TRUE;
return TRUE;
}
void
......
......@@ -234,8 +234,13 @@ nautilus_app_init (NautilusApp *app)
/* Init undo manager */
app->undo_manager = BONOBO_OBJECT (nautilus_undo_manager_new ());
undo_manager = bonobo_object_corba_objref (BONOBO_OBJECT (app->undo_manager));
/* Fix this */
Bonobo_Unknown_ref (undo_manager, &ev);
/* Stash a global reference to the object */
nautilus_undo_manager_stash_global_undo (undo_manager);
/* Add it to the application object*/
nautilus_attach_undo_manager ( GTK_OBJECT (app), undo_manager);
CORBA_exception_free (&ev);
......
......@@ -293,10 +293,10 @@ nautilus_view_frame_construct_arg_set(NautilusViewFrame *view)
if(view->construct_arg_count >= nca)
return;
view->construct_arg_count++;
if((view->construct_arg_count >= nca)
&& klass->view_constructed)
klass->view_constructed(view);
view->construct_arg_count++;
if((view->construct_arg_count >= nca) && klass->view_constructed) {
klass->view_constructed(view);
}
}
static void
......@@ -359,85 +359,90 @@ nautilus_view_frame_handle_client_destroy_2(GtkObject *object, CORBA_Object cobj
gboolean /* returns TRUE if successful */
nautilus_view_frame_load_client(NautilusViewFrame *view, const char *iid)
{
CORBA_Object obj;
CORBA_Object zoomable;
CORBA_Environment ev;
int i;
NautilusViewComponentType *component_types[] = {
&nautilus_view_component_type,
&bonobo_subdoc_component_type,
&bonobo_control_component_type,
NULL
};
g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE);
if (iid == NULL)
return FALSE;
CORBA_exception_init(&ev);
nautilus_view_frame_destroy_client(view);
view->client_object = bonobo_object_activate(iid, 0);
if(!view->client_object)
return FALSE;
view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev);
view->zoomable_frame = impl_Nautilus_ZoomableFrame__create(view, &ev);
/* Now figure out which type of embedded object it is: */
for(i = 0; component_types[i] && !view->component_class; i++)
{
obj = Bonobo_Unknown_query_interface(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)),
CORBA_Object obj;
CORBA_Object zoomable;
Nautilus_Undo_Manager undo_manager;
NautilusUndoContext *undo_context;
CORBA_Environment ev;
int i;
NautilusViewComponentType *component_types[] = {
&nautilus_view_component_type,
&bonobo_subdoc_component_type,
&bonobo_control_component_type,
NULL
};
g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE);
if (iid == NULL)
return FALSE;
CORBA_exception_init(&ev);
nautilus_view_frame_destroy_client(view);
view->client_object = bonobo_object_activate(iid, 0);
if(!view->client_object)
return FALSE;
view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev);
view->zoomable_frame = impl_Nautilus_ZoomableFrame__create(view, &ev);
/* Add undo manager to component */
undo_manager = nautilus_undo_manager_get_global_undo ();
g_assert (undo_manager);
undo_context = nautilus_undo_context_new (undo_manager);
bonobo_object_add_interface (BONOBO_OBJECT (view->view_frame), BONOBO_OBJECT (undo_context));
/* Now figure out which type of embedded object it is: */
for(i = 0; component_types[i] && !view->component_class; i++)
{
obj = Bonobo_Unknown_query_interface(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)),
component_types[i]->primary_repoid, &ev);
if(ev._major != CORBA_NO_EXCEPTION)
obj = CORBA_OBJECT_NIL;
if(ev._major != CORBA_NO_EXCEPTION)
obj = CORBA_OBJECT_NIL;
if(CORBA_Object_is_nil(obj, &ev))
continue;
if(CORBA_Object_is_nil(obj, &ev))
continue;
zoomable = bonobo_object_query_interface (BONOBO_OBJECT (view->client_object),
zoomable = bonobo_object_query_interface (BONOBO_OBJECT (view->client_object),
"IDL:Nautilus/Zoomable:1.0");
view->zoomable = zoomable;
view->zoomable = zoomable;
if(component_types[i]->try_load(view, obj, &ev))
view->component_class = component_types[i];
if(component_types[i]->try_load(view, obj, &ev))
view->component_class = component_types[i];
Bonobo_Unknown_unref(obj, &ev);
CORBA_Object_release(obj, &ev);
Bonobo_Unknown_unref(obj, &ev);
CORBA_Object_release(obj, &ev);
if (view->component_class)
break;
}
if (view->component_class)
break;
}
if (!view->component_class)
{
/* Nothing matched */
nautilus_view_frame_destroy_client(view);
return FALSE;
}
if (!view->component_class) {
/* Nothing matched */
nautilus_view_frame_destroy_client(view);
return FALSE;
}
view->iid = g_strdup(iid);
view->iid = g_strdup(iid);
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "destroy",
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "destroy",
GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy), view,
GTK_OBJECT(view));
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "object_gone",
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "object_gone",
GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy_2), view,
GTK_OBJECT(view));
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "system_exception",
gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "system_exception",
GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy_2), view,
GTK_OBJECT(view));
gtk_container_add(GTK_CONTAINER(view), view->client_widget);
gtk_widget_show(view->client_widget);
CORBA_exception_free(&ev);
gtk_container_add(GTK_CONTAINER(view), view->client_widget);
gtk_widget_show(view->client_widget);
CORBA_exception_free(&ev);
return TRUE;
return TRUE;
}
void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment