- Fixed eInstance_Evolve to properly readjust classes when evolving from GuiApplication as well
- Now adjusting all classes throughout all modules when evolving
- Fixed Window class vs Application's Window classes pureVtbl mix up due to Skin selection before app was reloaded
(Review copying of base window data into derived classes... pureVtbl is a class_data which really should not be copied)
- Fixed leaking GuiApplication which was constructed twice
- Cleaned up instance.ec global variables in __ecere_COM_Initialize() to support running with MemoryGuard
- Reviewed usage of __currentModule (-->__androidCurrentModule)/__thisModule in AndroidInterface.ec
private:
+#if defined(__ANDROID__)
+#include <android/log.h>
+
+#define printf(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "ecere-app", __VA_ARGS__))
+#endif
+
#undef property
#undef bool
#undef uint
if(totalSizeClass)
{
_class.data = renew _class.data byte[totalSizeClass];
+ // Class Data is often not inherited... e.g. Window::pureVtbl problem
// memset(_class.data, 0, totalSizeClass);
if(base && base.type != systemClass && base.type != enumClass)
memcpy(_class.data, base.data, offsetClass);
{
if(_class && instancePtr && *instancePtr)
{
+ bool wasApp = false, wasGuiApp = false;
Instance instance = (Instance)renew *instancePtr byte[_class.structSize];
*instancePtr = instance;
memset(((byte *)instance) + instance._class.structSize, 0, _class.structSize - instance._class.structSize);
// Fix pointers to application
- if(!strcmp(instance._class.name, "Application"))
+ if((wasApp = !strcmp(instance._class.name, "Application")) ||
+ (wasGuiApp = !strcmp(instance._class.name, "GuiApplication")))
{
Module module;
Application app = (Application) instance;
template.module = _class.module;
}
}
+
+ for(module = app.allModules.first; module; module = module.next)
+ {
+ for(_class = module.classes.first; _class; _class = _class.next)
+ {
+ OldLink templateLink;
+ _class.module = module;
+ for(templateLink = _class.templatized.first; templateLink; templateLink = templateLink.next)
+ {
+ Class template = templateLink.data;
+ template.module = _class.module;
+ }
+ }
+ }
+
app.application = app;
}
// Copy the virtual table initially
instance._vTbl = _class._vTbl;
+ if(_class.Constructor)
+ {
+ if(!_class.Constructor(instance))
+ {
+ for(; _class; _class = _class.base)
+ {
+ if(_class.templateClass) _class = _class.templateClass;
+ if(_class.Destructor)
+ _class.Destructor(instance);
+ }
+ _free(instance);
+ *instancePtr = null;
+ }
+ }
+ (_class.templateClass ? _class.templateClass : _class).count++;
+ // We don't want to reconstruct the portion already constructed...
+ /*
if(!ConstructInstance(instance, _class))
{
_free(instance);
*instancePtr = null;
}
+ */
}
}
{
Application app;
+ // Clean up global variables
+ memoryInitialized = false;
+ pools = null;
+#ifdef MEMINFO
+ memset(&memStacks, 0, sizeof(BinaryTree));
+ memoryErrorsCount = 0;
+ memset(&memBlocks, 0, sizeof(BinaryTree));
+ recurse = false;
+ blockID = 0;
+ allocateClass = null;
+ allocateInternal = false;
+ TOTAL_MEM = 0;
+ OUTSIDE_MEM = 0;
+#endif
+
#ifdef _DEBUG
// printf("Using debug ecere runtime library\n");
#endif
if(!link) skin = null;
if(skin)
+#if !defined(__ANDROID__)
SelectSkin(skin.name);
+#else
+ currentSkin = skin;
+#endif
}
}
app.cleanup();
app.Wait();
delete androidActivity;
- delete __currentModule;
+ delete __androidCurrentModule;
LOGV("THE END.");
}
guiApp = null;
desktopW = 0; desktopH = 0;
clipBoardData = null;
+ __thisModule = null;
+ __androidCurrentModule = null;
LOGV("Creating: %p\n", activity);
androidArgv[0] = moduleName;
// Create a base Application class
- __thisModule = __currentModule = __ecere_COM_Initialize(true, 1, androidArgv);
+ __androidCurrentModule = __ecere_COM_Initialize(true, 1, androidArgv);
// Load up Ecere
- eModule_Load(__currentModule, "ecere", publicAccess);
+ eModule_Load(__androidCurrentModule, "ecere", publicAccess);
+
if(activity->internalDataPath) PrintLn("internalDataPath is ", activity->internalDataPath);
if(activity->externalDataPath) PrintLn("externalDataPath is ", activity->externalDataPath);
extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp;
private:
-static Module __currentModule;
+static Module __androidCurrentModule;
static char * androidArgv[1];
static int desktopW, desktopH;
Module app;
// Evolve the Application class into a GuiApplication
- eInstance_Evolve((Instance *)&__currentModule, class(GuiApplication));
- __thisModule = __currentModule;
+ eInstance_Evolve((Instance *)&__androidCurrentModule, class(GuiApplication));
// Wait for the initWindow command:
guiApp.interfaceDriver = class(AndroidInterface);
}
// Invoke __ecereDll_Load() in lib[our package name].so
- app = eModule_Load(__currentModule, moduleName, publicAccess);
+ app = eModule_Load(__androidCurrentModule, moduleName, publicAccess);
if(app)
{
Class c;
if(!c) c = class(GuiApplication);
// Evolve the Application into it
- eInstance_Evolve((Instance *)&__currentModule, c);
- __thisModule = __currentModule;
+ eInstance_Evolve((Instance *)&__androidCurrentModule, c);
+ guiApp = (GuiApplication)__androidCurrentModule;
+ {
+ String skin = guiApp.skin;
+ *&guiApp.currentSkin = null;
+ guiApp.SelectSkin(skin);
+ }
// Call Main()
- __currentModule._vTbl[12](__currentModule);
+ __androidCurrentModule._vTbl[12](__androidCurrentModule);
}
if(!destroyRequested)
#if defined(__WIN32__)
return (int)GetCurrentThreadId();
#else
- return pthread_self();
+ return (int)pthread_self();
#endif
}