Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions src/gtkutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@

#include "package.h"

// set when we're processing some events to update the GUI ... used to sanity
// check eg. reduce (we mustn't call reduce from inside the nested loop,
// it'll crash into the main reduce thread)
gboolean in_update = FALSE;

void
set_glabel(GtkWidget *label, const char *fmt, ...)
{
Expand Down Expand Up @@ -255,34 +250,6 @@ get_state_int(GtkWidget *from, const char *name)
return g_variant_get_int32(state);
}

/* A 'safe' way to run a few events.
*/
void
process_events(void)
{
/* Max events we process before signalling a timeout. Without this we
* can get stuck in event loops in some circumstances.
*/
static const int max_events = 100;

/* Block too much recursion. 0 is from the top-level, 1 is from a
* callback, we don't want any more than that.
*/
if (!in_update &&
g_main_depth() < 2) {
int n;

in_update = TRUE;

for (n = 0; n < max_events &&
g_main_context_iteration(NULL, FALSE);
n++)
;

in_update = FALSE;
}
}

static gboolean
block_scroll_cb(GtkEventControllerScroll *self,
gdouble dx, gdouble dy, gpointer user_data)
Expand Down
5 changes: 0 additions & 5 deletions src/gtkutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@
#define PARENT_CLASS_DYNAMIC(OBJECT) \
(g_type_class_peek(g_type_parent(G_TYPE_FROM_INSTANCE(OBJECT))))

// TRUE for in a nested mainloop
extern gboolean in_update;

void set_glabel(GtkWidget *label, const char *fmt, ...);
void set_glabel1(GtkWidget *label, const char *fmt, ...);
void set_gentryv(GtkWidget *edit, const char *fmt, va_list ap);
Expand All @@ -85,8 +82,6 @@ gboolean get_state_bool(GtkWidget *from, const char *name);
double get_state_double(GtkWidget *from, const char *name);
int get_state_int(GtkWidget *from, const char *name);

void process_events(void);

void block_scroll(GtkWidget *widget);

gboolean widget_should_animate(GtkWidget *widget);
Expand Down
4 changes: 0 additions & 4 deletions src/progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ progress_emit_begin(Progress *progress)
static gboolean
progress_emit_update(Progress *progress)
{
process_events();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps these are still needed for nip4, I haven't checked.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, nip4 still needs these for eg. progress updates during workspace recomp. Though it'd probably be better to do recomp as a series of tasks rather than one task with a nested main loop.


gboolean cancel = FALSE;
g_signal_emit(progress, progress_signals[SIG_UPDATE], 0, &cancel);

Expand Down Expand Up @@ -240,8 +238,6 @@ progress_event_signal(ProgressEvent *event)
{
Progress *progress = progress_get();

process_events();

/* Throttle update events to 10Hz.
*/
if (event->signal == SIG_UPDATE) {
Expand Down
37 changes: 28 additions & 9 deletions src/saveoptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,25 +295,44 @@ save_options_set_argument(VipsObject *operation,
}

static void
save_options_ok_action(GSimpleAction *action,
GVariant *parameter, gpointer user_data)
save_options_build_thread(GTask *task,
gpointer source_object, gpointer task_data, GCancellable *cancellable)
{
SaveOptions *options = SAVE_OPTIONS(user_data);
SaveOptions *options = SAVE_OPTIONS(source_object);

vips_argument_map(VIPS_OBJECT(options->save_operation),
save_options_set_argument, options, NULL);
g_task_return_boolean(task,
vips_cache_operation_buildp(&options->save_operation));
}

// this will trigger the save and loop while we write ... the
// UI will stay live thanks to event processing in the eval
// handler
if (vips_cache_operation_buildp(&options->save_operation))
static void
save_options_build_done(GObject *source,
GAsyncResult *result, gpointer user_data)
{
SaveOptions *options = SAVE_OPTIONS(source);

if (g_task_propagate_boolean(G_TASK(result), NULL))
save_options_error(options);
else
// everything worked, we can post success back to
// our caller
gtk_window_destroy(GTK_WINDOW(options));
}

static void
save_options_ok_action(GSimpleAction *action,
GVariant *parameter, gpointer user_data)
{
SaveOptions *options = SAVE_OPTIONS(user_data);

vips_argument_map(VIPS_OBJECT(options->save_operation),
save_options_set_argument, options, NULL);

g_autoptr(GTask) task = g_task_new(options, NULL,
save_options_build_done, NULL);

g_task_run_in_thread(task, save_options_build_thread);
}

static void
save_options_cancel_action(GSimpleAction *action,
GVariant *parameter, gpointer user_data)
Expand Down
Loading