Skip to content

Commit cfd4a86

Browse files
Redefine dt_control_running()
It's now implemented as an inline function checking for darktable.control == NULL, if so write caller, file and position to the logs. control-last_expose_time was not used at all so it got removed.
1 parent bd3bd3c commit cfd4a86

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/control/control.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ void dt_control_init(const gboolean withgui)
220220
// same thread as init
221221
s->gui_thread = pthread_self();
222222

223-
// s->last_expose_time = dt_get_wtime();
224223
s->log_pos = s->log_ack = 0;
225224
s->busy = 0;
226225
s->log_message_timeout_id = 0;
@@ -283,11 +282,6 @@ void dt_control_change_cursor(dt_cursor_t curs)
283282
via DT_CONTROL_STATE_CLEANUP before doing so.
284283
*/
285284

286-
gboolean dt_control_running()
287-
{
288-
return darktable.control && dt_atomic_get_int(&darktable.control->running) == DT_CONTROL_STATE_RUNNING;
289-
}
290-
291285
void dt_control_quit()
292286
{
293287
// Make sure we proceed further only if control is running

src/control/control.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ typedef struct dt_control_t
175175

176176
// gui settings
177177
dt_pthread_mutex_t global_mutex, image_mutex;
178-
double last_expose_time;
179178

180179
// job management
181180
dt_atomic_int running;
@@ -248,7 +247,20 @@ void dt_control_cleanup(const gboolean withgui);
248247
void dt_control_quit(void);
249248

250249
/** get threadsafe running state. */
251-
gboolean dt_control_running(void);
250+
#define dt_control_running() _control_running_with_caller(__FILE__, __LINE__, __FUNCTION__)
251+
static inline gboolean _control_running_with_caller(const char *file,
252+
const int line,
253+
const char *function)
254+
{
255+
dt_control_t *c = darktable.control;
256+
if(!c)
257+
{
258+
dt_print(DT_DEBUG_ALWAYS, "undefined control in '%s': `%s:%d`", function, file, line);
259+
return FALSE;
260+
}
261+
else
262+
return dt_atomic_get_int(&c->running) == DT_CONTROL_STATE_RUNNING;
263+
}
252264

253265
// thread-safe interface between core and gui.
254266
// is the locking really needed?

0 commit comments

Comments
 (0)