Index: src/plugins/query/dlg_search.c =================================================================== --- src/plugins/query/dlg_search.c (revision 10335) +++ src/plugins/query/dlg_search.c (revision 10336) @@ -66,6 +66,7 @@ typedef struct{ RND_DAD_DECL_NOINIT(dlg) + rnd_design_t *dsg; /* used when follow is set */ int wexpr_str, wwizard, wact, wscope, wscope_label, wfollow; int wrowbox[MAX_ROW]; int wexpr[MAX_ROW][MAX_COL]; /* expression framed box */ @@ -140,10 +141,19 @@ rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->wexpr_str, !wen); } +static rnd_design_t *get_design(search_ctx_t *ctx) +{ + + if (ctx->dlg[ctx->wfollow].val.lng) + return ctx->dsg; + return rnd_gui->get_dad_design(ctx->dlg_hid_ctx); +} + static void update_scope(search_ctx_t *ctx) { rnd_hid_attr_val_t hv; - rnd_design_t *ctx_hl = rnd_gui->get_dad_design(ctx->dlg_hid_ctx); + rnd_design_t *ctx_hl = get_design(ctx); + rnd_project_t *prj = ctx_hl->project; char *freeme = NULL; @@ -172,7 +182,6 @@ hv.str = ""; rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->wscope_label, &hv); - rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->wfollow, 0); free(freeme); } @@ -513,7 +522,11 @@ static void search_apply_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) { search_ctx_t *ctx = caller_data; - rnd_design_t *hidlib = rnd_gui->get_dad_design(hid_ctx); + rnd_design_t *hidlib = get_design(ctx); + if (hidlib == NULL) { + rnd_message(RND_MSG_ERROR, "Can't search: invalid scope\n"); + return; + } if (ctx->dlg[ctx->wexpr_str].val.str != NULL) { const char *op = search_acts[ctx->dlg[ctx->wact].val.lng]; const char *scp = search_scopes[ctx->dlg[ctx->wscope].val.lng]; @@ -656,6 +669,7 @@ RND_DAD_DEFSIZE(ctx->dlg, 300, 350); RND_DAD_NEW("search", ctx->dlg, "sch-rnd search", ctx, rnd_false, search_close_cb); /* type=local */ + ctx->dsg = rnd_gui->get_dad_design(ctx->dlg_hid_ctx); ctx->visible[0][0] = 1; update_vis(ctx); update_scope(ctx); @@ -683,7 +697,7 @@ { search_ctx_t *ctx, *nextctx; for(ctx = gdl_first(&searches); ctx != NULL; ctx = nextctx) { - rnd_design_t *ctx_hl = rnd_gui->get_dad_design(ctx->dlg_hid_ctx); + rnd_design_t *ctx_hl = get_design(ctx); nextctx = gdl_next(&searches, ctx); if (ctx_hl == hidlib) search_close(ctx);