Project

Profile

Help

Revision 4ee4355d

Added by O'Neil Delpratt 5 months ago

Saxon/C bug fixes with exception handling and other

View differences:

src/main/c/Saxon.C.API/XdmValue.cpp
128 128
XdmValue::~XdmValue() {
129 129
	//bool safeToClear = false;
130 130
	//std::cout<<"xdmValue destructor size= "<<values.size()<<" ref="<<getRefCount()<<" Pointer = "<<(this)<<std::endl;
131
    //if(getRefCount()<1){
132
	//proc->env->ReleaseObject
133 131
	if(values.size() > 0) {
134 132
        for (size_t i = 0; i < values.size(); i++) {
135
            values[i]->decrementRefCount();
136
            if (values[i] != nullptr && values[i]->getRefCount() < 1) {
133
            if (values[i] != nullptr) {
134
                //values[i]->decrementRefCount();
137 135
                delete values[i];
138 136
            }
139 137
        }
......
141 139
    }
142 140
	if (valueType != nullptr) { delete valueType; }
143 141
	if (jValues) {
144
		SaxonProcessor::sxn_environ->env->DeleteLocalRef(jValues);
142
		SaxonProcessor::sxn_environ->env->DeleteGlobalRef(jValues);
145 143
	}
146 144
	xdmSize = 0;
147 145

  
148
    //}
149

  
150 146
    if(!toStringValue.empty()) {
151 147
        toStringValue.clear();
152 148
    }
......
159 155
        val->incrementRefCount();
160 156
		xdmSize++;
161 157
        if (jValues) {
162
            std::cout<<"xdmValue jni"<<getRefCount()<<std::endl;
163
            SaxonProcessor::sxn_environ->env->DeleteLocalRef(jValues);  //TODO check - this maybe should be DeleteGlobalRef  - check where it is created
158
            SaxonProcessor::sxn_environ->env->DeleteGlobalRef(jValues);
164 159
            jValues = nullptr;
165 160
        }
166 161

  
......
222 217
}
223 218

  
224 219
void XdmValue::releaseXdmValue() {
220
    for (size_t i = 0; i < values.size(); i++) {
221
        if (values[i] != nullptr) {
222
            delete values[i];
223
        }
224
    }
225 225

  
226
    if(jValues) {
227
        SaxonProcessor::sxn_environ->env->DeleteGlobalRef(jValues);
228
    }
226 229

  
227 230

  
228 231
}

Also available in: Unified diff