Collection IO: Enable file exporters to be specified on Collections #116646
|
@ -162,10 +162,6 @@ static void io_handler_item_free(IOHandlerData *data)
|
|||
IDP_FreeProperty(data->export_properties);
|
||||
data->export_properties = nullptr;
|
||||
}
|
||||
if (data->export_ptr) {
|
||||
MEM_freeN(data->export_ptr);
|
||||
data->export_ptr = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void collection_free_data(ID *id)
|
||||
|
@ -335,7 +331,6 @@ void BKE_collection_blend_read_data(BlendDataReader *reader, Collection *collect
|
|||
|
||||
BLO_read_list(reader, &collection->io_handlers);
|
||||
LISTBASE_FOREACH (IOHandlerData *, data, &collection->io_handlers) {
|
||||
data->export_ptr = nullptr;
|
||||
BLO_read_data_address(reader, &data->export_properties);
|
||||
IDP_BlendDataRead(reader, &data->export_properties);
|
||||
}
|
||||
|
|
|
@ -2363,18 +2363,18 @@ void uiTemplateCollectionExporters(uiLayout *layout, bContext *C)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!data->export_ptr) {
|
||||
data->export_ptr = MEM_cnew<PointerRNA>("wmOpItemPtr");
|
||||
WM_operator_properties_create(data->export_ptr, fh->export_operator);
|
||||
data->export_ptr->data = data->export_properties;
|
||||
wmOperatorType *ot = WM_operatortype_find(fh->export_operator, false);
|
||||
if (!ot) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PointerRNA ptr = RNA_pointer_create(nullptr, ot->srna, data->export_properties);
|
||||
|
||||
/* TEMP: Just draw the properties like the KeyMap editor for debugging. */
|
||||
PointerRNA *ptr = data->export_ptr;
|
||||
uiLayout *flow = uiLayoutColumnFlow(layout, 2, false);
|
||||
|
||||
RNA_STRUCT_BEGIN_SKIP_RNA_TYPE (ptr, prop) {
|
||||
const bool is_set = RNA_property_is_set(ptr, prop);
|
||||
RNA_STRUCT_BEGIN_SKIP_RNA_TYPE (&ptr, prop) {
|
||||
const bool is_set = RNA_property_is_set(&ptr, prop);
|
||||
uiBut *but;
|
||||
|
||||
/* TEMP: Just filter out some extra stuff for better debug layout. */
|
||||
|
@ -2394,7 +2394,7 @@ void uiTemplateCollectionExporters(uiLayout *layout, bContext *C)
|
|||
uiLayout *row = uiLayoutRow(box, false);
|
||||
|
||||
/* property value */
|
||||
uiItemFullR(row, ptr, prop, -1, 0, UI_ITEM_NONE, nullptr, ICON_NONE);
|
||||
uiItemFullR(row, &ptr, prop, -1, 0, UI_ITEM_NONE, nullptr, ICON_NONE);
|
||||
|
||||
if (is_set) {
|
||||
/* unset operator */
|
||||
|
@ -2410,7 +2410,7 @@ void uiTemplateCollectionExporters(uiLayout *layout, bContext *C)
|
|||
UI_UNIT_X,
|
||||
UI_UNIT_Y,
|
||||
nullptr);
|
||||
but->rnapoin = *ptr;
|
||||
but->rnapoin = ptr;
|
||||
but->rnaprop = prop;
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "BKE_collection.h"
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_file_handler.hh"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.hh"
|
||||
|
@ -443,9 +444,8 @@ static int collection_io_handler_add_exec(bContext *C, wmOperator *op)
|
|||
IOHandlerData *data = MEM_cnew<IOHandlerData>("IOHandlerData");
|
||||
STRNCPY(data->fh_idname, fh->idname);
|
||||
|
||||
WM_operator_properties_alloc(&data->export_ptr, &data->export_properties, fh->export_operator);
|
||||
WM_operator_properties_sanitize(data->export_ptr, true);
|
||||
data->export_ptr->owner_id = nullptr;
|
||||
IDPropertyTemplate val{};
|
||||
data->export_properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp");
|
||||
|
||||
deadpin marked this conversation as resolved
Outdated
|
||||
BLI_addtail(io_handlers, data);
|
||||
|
||||
|
@ -483,11 +483,15 @@ static int collection_debug_io_exec(bContext *C, wmOperator * /*op*/)
|
|||
continue;
|
||||
}
|
||||
|
||||
wmOperatorType *ot = WM_operatortype_find(fh->export_operator, false);
|
||||
if (!ot) {
|
||||
continue;
|
||||
}
|
||||
printf("DEBUG: Invoking %s\n", fh->export_operator);
|
||||
|
||||
/* Invoke operator with the properties stored on the Collection. */
|
||||
wmOperatorType *ot = WM_operatortype_find(fh->export_operator, false);
|
||||
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, data->export_ptr, nullptr);
|
||||
PointerRNA ptr = RNA_pointer_create(nullptr, ot->srna, data->export_properties);
|
||||
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &ptr, nullptr);
|
||||
|
||||
/* TODO: Should we continue calling operators if one fails? */
|
||||
/* TODO: What's the best way to surface the problem? Reports? */
|
||||
|
|
|
@ -71,7 +71,6 @@ typedef struct IOHandlerData {
|
|||
char fh_idname[64];
|
||||
|
||||
IDProperty *export_properties;
|
||||
struct PointerRNA *export_ptr;
|
||||
} IOHandlerData;
|
||||
|
||||
/* Light linking state of object or collection: defines how they react to the emitters in the
|
||||
|
|
Loading…
Reference in New Issue
io_wmOpItemProp
is a bit of a strange name. Any reason it's notexport_properties
?