if the active display becomes NULL (e.g. by closing a view), don't leave

2004-11-24  Michael Natterer  <mitch@gimp.org>

	* app/gui/gui.c (gui_display_changed): if the active display
	becomes NULL (e.g. by closing a view), don't leave the user
	context with an image but no display. Instead, try to find another
	display of the same image instead and if that fails set the image
	to NULL.

	Prevents the various foo_actions_update() functions from being
	called with a NULL display while there is still an active image in
	the context.

	Fixes bug #159304.

	(Removed #warning about being misplaced from that function because
	it's a typical piece of ugly glue code that belongs exactly here).
This commit is contained in:
Michael Natterer 2004-11-24 16:41:52 +00:00 committed by Michael Natterer
parent b349746fc2
commit cdb165874f
2 changed files with 43 additions and 5 deletions

View File

@ -1,3 +1,20 @@
2004-11-24 Michael Natterer <mitch@gimp.org>
* app/gui/gui.c (gui_display_changed): if the active display
becomes NULL (e.g. by closing a view), don't leave the user
context with an image but no display. Instead, try to find another
display of the same image instead and if that fails set the image
to NULL.
Prevents the various foo_actions_update() functions from being
called with a NULL display while there is still an active image in
the context.
Fixes bug #159304.
(Removed #warning about being misplaced from that function because
it's a typical piece of ugly glue code that belongs exactly here).
2004-11-24 Simon Budig <simon@gimp.org>
* modules/controller_linux_input.c: Accept >= 0 return values of the

View File

@ -35,6 +35,7 @@
#include "core/gimpcontext.h"
#include "core/gimpenvirontable.h"
#include "core/gimpimage.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay.h"
@ -573,16 +574,36 @@ gui_device_change_notify (Gimp *gimp)
}
}
#ifdef __GNUC__
#warning FIXME: this junk should mostly go to the display subsystem
#endif
static void
gui_display_changed (GimpContext *context,
GimpDisplay *display,
Gimp *gimp)
{
if (! display)
{
GimpImage *image = gimp_context_get_image (context);
if (image)
{
GList *list;
for (list = GIMP_LIST (gimp->displays)->list;
list;
list = g_list_next (list))
{
GimpDisplay *display2 = list->data;
if (display2->gimage == image)
{
gimp_context_set_display (context, display2);
return;
}
}
gimp_context_set_image (context, NULL);
}
}
gimp_ui_manager_update (image_ui_manager, display);
}