Thanks. That Looks like my code.
But you can end up having a bad memory lock, too.
One which failed to initialize.
Maybe I should query size and see if it is >0?
if (!ref)
ref = REALGetClassRef("MemoryBlock");
if (ref) {
REALmemoryBlock m = REALnewInstance(ref);
_STATIC_ void (*_fp)(REALmemoryBlock, RBUInteger) = nil;
if (!_fp)
_fp = (void(*)(REALmemoryBlock, RBUInteger)) REALLoadObjectMethod(m, "Constructor(length as Integer)");
if (_fp) {
_fp(m, len);
return m;
}
REALUnlockObject(m);
MSG(DYNAMIC ACCESS FAILURE in MemoryBlock_New)
return NULL;
}
MSG(DYNAMIC ACCESS: COULD NOT GET REALGetClassRef in MemoryBlock_New)
return NULL;
}
[/code]
If the class ref is NULL then you know you should call REALGetClassRef(“MemoryBlock”) in PluginEntry(). And if dynamic access fails (and the code above is ok) then a feedback report is required.
Yes, but expand your scope past things that allocate big memory chunks.
Basically anything returned by REALLoadObjectMethod can raise an exception, along with REALGetPropValue, REALSetPropValue, REALGetEventInstance, REALUnlockObject, all of the array functions, and anything else that executes Xojo code. Even some of the older now-deprecated functions could throw in certain situations.
It’s all rather unfortunate, but adding non-throwing wrappers for every framework function a plugin might ever be interested in isn’t the answer.
[quote=214691:@Christian Schmitz]So Xojo runtime jumps out of my code?
I thought exceptions are just stored for later?[/quote]
No, it won’t jump out of your code. Control flow continues in your C++ code until it gets back to Xojo code, where it jumps to the appropriate exception handler.
It can. With some of C++11 metaprogramming, I think you can even make it fairly elegant.
Lord Christian !! you need to do your self a favour and make the jump to 2015 !! Its free and less painless than you might think. I made the jump from 2008 to 2013 earlier this year and then to 2015, its win win situation.
I guess I didn’t poor enough beer into you this summer to shake this out of you.
Only drawback was that I cannot run VS 2013 or 2015 on XP Virtual machines. But making good Windows 7 VM solved that, turning off all restore points and rubbish like that makes Windows 7 fairly light and reasonable on VMware.