Skip to content

Commit

Permalink
graph: don't write disconnect events to .cfg files
Browse files Browse the repository at this point in the history
  • Loading branch information
hanatos committed Jul 8, 2024
1 parent 8200a26 commit a7da449
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/pipe/graph-history.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dt_graph_history_reset(
// write all connections
for(uint32_t m=0;m<graph->num_modules;m++)
for(int c=0;c<graph->module[m].num_connectors;c++,i+=(hi[i+1]!=hi[i]))
if(!(hi[i+1] = dt_graph_write_connection_ascii(graph, m, c, hi[i], max-hi[i])))
if(!(hi[i+1] = dt_graph_write_connection_ascii(graph, m, c, hi[i], max-hi[i], 1)))
return 1;

// write all params
Expand Down Expand Up @@ -130,7 +130,7 @@ dt_graph_history_connection(
if(_dt_graph_history_check_buf(graph, 70)) return;
int i = graph->history_item_end;
char **hi = graph->history_item, *max = graph->history_pool + graph->history_max;
if(hi[i] < (hi[i+1] = dt_graph_write_connection_ascii(graph, modid, conid, hi[i], max - hi[i])))
if(hi[i] < (hi[i+1] = dt_graph_write_connection_ascii(graph, modid, conid, hi[i], max - hi[i], 1)))
{ *(hi[i+1]-1) = 0; graph->history_item_cur = ++graph->history_item_end; }
}

Expand Down
6 changes: 4 additions & 2 deletions src/pipe/graph-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,16 @@ dt_graph_write_connection_ascii(
const int m, // module index
const int i, // connector index on given module
char *line,
size_t size)
size_t size,
int allow_empty)
{
if(graph->module[m].name == 0) return line;
dt_connector_t *c = graph->module[m].connector+i;
if(!dt_connector_input(c)) return line; // refuse to serialise outgoing connections
dt_token_t name, inst, conn;
if(c->connected_mi == -1)
{ // explicitly record disconnect event (important for history)
if(!allow_empty) return line; // don't write disconnect events explicitly
name = inst = conn = dt_token("-1");
}
else
Expand Down Expand Up @@ -490,7 +492,7 @@ int dt_graph_write_config_ascii(
// write all connections
for(int m=0;m<graph->num_modules;m++)
for(int i=0;i<graph->module[m].num_connectors;i++)
if(!(buf = dt_graph_write_connection_ascii(graph, m, i, buf, end-buf)))
if(!(buf = dt_graph_write_connection_ascii(graph, m, i, buf, end-buf, 0)))
goto error;

// write all params
Expand Down
3 changes: 2 additions & 1 deletion src/pipe/graph-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ dt_graph_write_connection_ascii(
const int m, // module index
const int i, // connector index on given module
char *line,
size_t size);
size_t size,
int write_empty); // also serialise disconnected inputs (for history)

// write param
VKDT_API char *
Expand Down
2 changes: 1 addition & 1 deletion src/pipe/modules/bs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DECLARE_FUNC(int, dt_module_connect, (dt_graph_t *graph, int n0, int c0, int
DECLARE_FUNC(int, dt_module_feedback, (dt_graph_t *graph, int n0, int c0, int n1, int c1));
DECLARE_FUNC(int, dt_module_remove, (dt_graph_t *graph, const int mid));
DECLARE_FUNC(int, dt_module_add, (dt_graph_t *graph, dt_token_t name, dt_token_t inst));
DECLARE_FUNC(char*, dt_graph_write_connection_ascii, (dt_graph_t *graph, const int m, const int i, char *line, size_t size));
DECLARE_FUNC(char*, dt_graph_write_connection_ascii, (dt_graph_t *graph, const int m, const int i, char *line, size_t size, int allow_empty));
DECLARE_FUNC(char*, dt_graph_write_param_ascii, (const dt_graph_t *graph, const int m, const int p, char *line, size_t size, char **eop));
DECLARE_FUNC(char*, dt_graph_write_module_ascii, (const dt_graph_t *graph, const int m, char *line, size_t size));
DECLARE_VAR(dt_pipe_global_t, dt_pipe);
Expand Down

0 comments on commit a7da449

Please sign in to comment.