diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-04-03 19:18:59 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-04-03 19:18:59 +0400 |
commit | 123f7d3eb3e7ba14c05e4097a57119bf75e08019 (patch) | |
tree | 2cb3eacdc38914e43a509cdd168c921a9174344d /source/blender/blenkernel/intern/context.c | |
parent | f137ba074abb599ea2b4226f47a4234cb6995f1e (diff) |
Popup menu layout inherits context store from button.
When adding extra context data in a layout using uiLayoutSetContextPointer, this info was not inherited by popup menus generated in this layout. While operators from regular buttons work fine, the data is missing in operators from menus and such. This patch copies the bContextStore from buttons to the new uiLayout used for popups.
Diffstat (limited to 'source/blender/blenkernel/intern/context.c')
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index a725b5f4c52..e9dd4d01b0e 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -141,6 +141,35 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p return ctx; } +bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context) +{ + bContextStoreEntry *entry, *tentry; + bContextStore *ctx, *lastctx; + + /* ensure we have a context to put the entries in, if it was already used + * we have to copy the context to ensure */ + ctx= contexts->last; + + if (!ctx || ctx->used) { + if (ctx) { + lastctx= ctx; + ctx= MEM_dupallocN(lastctx); + BLI_duplicatelist(&ctx->entries, &lastctx->entries); + } + else + ctx= MEM_callocN(sizeof(bContextStore), "bContextStore"); + + BLI_addtail(contexts, ctx); + } + + for (tentry= context->entries.first; tentry; tentry= tentry->next) { + entry= MEM_dupallocN(tentry); + BLI_addtail(&ctx->entries, entry); + } + + return ctx; +} + void CTX_store_set(bContext *C, bContextStore *store) { C->wm.store= store; |