| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fbcd00e commit ab1595d
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,6 +42,10 @@ | |||
| 42 | 42 | wrapper->raw->{{ field.name }} = {% if not field.cType | isPointer %}*{% endif %}ObjectWrap::Unwrap<{{ field.cppClassName }}>(value->ToObject())->GetValue(); | |
| 43 | 43 | ||
| 44 | 44 | {% elsif field.isCallbackFunction %} | |
| 45 | + if (wrapper->{{ field.name }} != NULL) { | ||
| 46 | + delete wrapper->{{ field.name }}; | ||
| 47 | + } | ||
| 48 | + | ||
| 45 | 49 | if (value->IsFunction()) { | |
| 46 | 50 | if (!wrapper->raw->{{ field.name }}) { | |
| 47 | 51 | wrapper->raw->{{ field.name }} = ({{ field.cType }}){{ field.name }}_cppCallback; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,8 +41,19 @@ using namespace std; | |||
| 41 | 41 | } | |
| 42 | 42 | ||
| 43 | 43 | {{ cppClassName }}::~{{ cppClassName }}() { | |
| 44 | - // This is going to cause memory leaks. We'll have to solve that later | ||
| 45 | - // TODO: Clean up memory better | ||
| 44 | + {% each fields|fieldsInfo as field %} | ||
| 45 | + {% if not field.ignore %} | ||
| 46 | + {% if not field.isEnum %} | ||
| 47 | + {% if field.isCallbackFunction %} | ||
| 48 | + if (this->{{ field.name }} != NULL) { | ||
| 49 | + delete this->{{ field.name }}; | ||
| 50 | + this->raw->{{ fields|payloadFor field.name }} = NULL; | ||
| 51 | + } | ||
| 52 | + {% endif %} | ||
| 53 | + {% endif %} | ||
| 54 | + {% endif %} | ||
| 55 | + {% endeach %} | ||
| 56 | + | ||
| 46 | 57 | if (this->selfFreeing) { | |
| 47 | 58 | free(this->raw); | |
| 48 | 59 | } | |
@@ -65,7 +76,7 @@ void {{ cppClassName }}::ConstructFields() { | |||
| 65 | 76 | // the current instance | |
| 66 | 77 | this->raw->{{ field.name }} = NULL; | |
| 67 | 78 | this->raw->{{ fields|payloadFor field.name }} = (void *)this; | |
| 68 | - this->{{ field.name }} = new NanCallback(); | ||
| 79 | + this->{{ field.name }} = NULL; | ||
| 69 | 80 | {% elsif field.payloadFor %} | |
| 70 | 81 | ||
| 71 | 82 | Local<Value> {{ field.name }} = NanUndefined(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments