fix for node clipboard leak on exit, also use blenders convention for function naming with BKE clipboard funcs.

This commit is contained in:
Campbell Barton
2012-08-06 08:25:24 +00:00
parent 00ea79afa0
commit 5bb97305a4
4 changed files with 23 additions and 21 deletions

View File

@@ -386,11 +386,11 @@ int nodeSocketIsHidden(struct bNodeSocket *sock);
void nodeSocketSetType(struct bNodeSocket *sock, int type);
/* Node Clipboard */
void nodeClipboardClear(void);
void nodeClipboardAddNode(struct bNode *node);
void nodeClipboardAddLink(struct bNodeLink *link);
const struct ListBase *nodeClipboardGetNodes(void);
const struct ListBase *nodeClipboardGetLinks(void);
void BKE_node_clipboard_clear(void);
void BKE_node_clipboard_add_node(struct bNode *node);
void BKE_node_clipboard_add_link(struct bNodeLink *link);
const struct ListBase *BKE_node_clipboard_get_nodes(void);
const struct ListBase *BKE_node_clipboard_get_links(void);
/* ************** NODE TYPE ACCESS *************** */

View File

@@ -1432,7 +1432,7 @@ typedef struct bNodeClipboard {
bNodeClipboard node_clipboard;
void nodeClipboardClear(void)
void BKE_node_clipboard_clear(void)
{
bNode *node, *node_next;
bNodeLink *link, *link_next;
@@ -1450,22 +1450,22 @@ void nodeClipboardClear(void)
node_clipboard.nodes.first = node_clipboard.nodes.last = NULL;
}
void nodeClipboardAddNode(bNode *node)
void BKE_node_clipboard_add_node(bNode *node)
{
BLI_addtail(&node_clipboard.nodes, node);
}
void nodeClipboardAddLink(bNodeLink *link)
void BKE_node_clipboard_add_link(bNodeLink *link)
{
BLI_addtail(&node_clipboard.links, link);
}
const ListBase *nodeClipboardGetNodes(void)
const ListBase *BKE_node_clipboard_get_nodes(void)
{
return &node_clipboard.nodes;
}
const ListBase *nodeClipboardGetLinks(void)
const ListBase *BKE_node_clipboard_get_links(void)
{
return &node_clipboard.links;
}

View File

@@ -1917,7 +1917,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
ED_preview_kill_jobs(C);
/* clear current clipboard */
nodeClipboardClear();
BKE_node_clipboard_clear();
/* get group node offset */
if (gnode)
@@ -1926,7 +1926,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
for (node = ntree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
new_node = nodeCopyNode(NULL, node);
nodeClipboardAddNode(new_node);
BKE_node_clipboard_add_node(new_node);
}
}
@@ -1968,7 +1968,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
newlink->fromnode = link->fromnode->new_node;
newlink->fromsock = link->fromsock->new_sock;
nodeClipboardAddLink(newlink);
BKE_node_clipboard_add_link(newlink);
}
}
@@ -2015,7 +2015,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *UNUSED(op))
/* calculate "barycenter" for placing on mouse cursor */
num_nodes = 0;
centerx = centery = 0.0f;
for (node = nodeClipboardGetNodes()->first; node; node = node->next) {
for (node = BKE_node_clipboard_get_nodes()->first; node; node = node->next) {
++num_nodes;
centerx += 0.5f * (node->totr.xmin + node->totr.xmax);
centery += 0.5f * (node->totr.ymin + node->totr.ymax);
@@ -2024,7 +2024,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *UNUSED(op))
centery /= num_nodes;
/* copy nodes from clipboard */
for (node = nodeClipboardGetNodes()->first; node; node = node->next) {
for (node = BKE_node_clipboard_get_nodes()->first; node; node = node->next) {
bNode *new_node = nodeCopyNode(ntree, node);
/* pasted nodes are selected */
@@ -2032,7 +2032,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *UNUSED(op))
}
/* reparent copied nodes */
for (node = nodeClipboardGetNodes()->first; node; node = node->next) {
for (node = BKE_node_clipboard_get_nodes()->first; node; node = node->next) {
bNode *new_node = node->new_node;
if (new_node->parent)
new_node->parent = new_node->parent->new_node;
@@ -2045,7 +2045,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *UNUSED(op))
}
}
for (link = nodeClipboardGetLinks()->first; link; link = link->next) {
for (link = BKE_node_clipboard_get_links()->first; link; link = link->next) {
nodeAddLink(ntree, link->fromnode->new_node, link->fromsock->new_sock,
link->tonode->new_node, link->tosock->new_sock);
}

View File

@@ -58,6 +58,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mball.h"
#include "BKE_node.h"
#include "BKE_report.h"
#include "BKE_packedFile.h"
@@ -334,10 +335,10 @@ static void free_openrecent(void)
/* bad stuff*/
// XXX copy/paste buffer stuff...
extern void free_anim_copybuf(void);
extern void free_anim_drivers_copybuf(void);
extern void free_fmodifiers_copybuf(void);
extern void free_posebuf(void);
extern void free_anim_copybuf(void);
extern void free_anim_drivers_copybuf(void);
extern void free_fmodifiers_copybuf(void);
extern void free_posebuf(void);
#if WIN32
/* Read console events until there is a key event. Also returns on any error. */
@@ -419,6 +420,7 @@ void WM_exit_ext(bContext *C, const short do_python)
free_anim_drivers_copybuf();
free_fmodifiers_copybuf();
free_posebuf();
BKE_node_clipboard_clear();
BLF_exit();