documentor; compiler/libec: Fixed crashes opening libraries
authorJerome St-Louis <jerome@ecere.com>
Wed, 18 Jun 2014 16:53:17 +0000 (12:53 -0400)
committerJerome St-Louis <jerome@ecere.com>
Wed, 18 Jun 2014 16:58:27 +0000 (12:58 -0400)
- Since daa244a0463d1dd97a42826cb44ff05278caf323 menus were getting messed up
  and Documentor would crash on exit after opening an ecere.dll/.so

compiler/libec/src/loadSymbols.ec
documentor/src/Documentor.ec

index e313f96..bb53b13 100644 (file)
@@ -36,6 +36,8 @@ bool inPreCompiler = false;
 public void SetInPreCompiler(bool b) {inPreCompiler = b; }
 bool inSymbolGen = false;
 public void SetInSymbolGen(bool b) {inSymbolGen = b; }
+bool inDocumentor = false;
+public void SetInDocumentor(bool b) { inDocumentor = b; }
 OldList * precompDefines;
 public void SetPrecompDefines(OldList * list) { precompDefines = list; }
 
@@ -784,7 +786,12 @@ public void ImportModule(const char * name, ImportType importType, AccessMode im
 
                // Load an extra instance of any shared module to ensure freeing up a
                // module loaded in another file will not invalidate our objects.
-               if(!inCompiler && !inPreCompiler && !inSymbolGen)
+
+               // Don't do this for Documentor, because files are loaded with full paths
+               // and won't be recognized as the same libecere that Documentor is actually using,
+               // and since this is loaded from the Documentor app module, it will invalidate classes in use.
+               // We only load one component app at a time for Documentor, so we do not need this trick.
+               if(!inCompiler && !inPreCompiler && !inSymbolGen && !inDocumentor)
                {
                   MapIterator<String, List<Module> > it { map = loadedModules };
                   if(!it.Index(name /*file*/, false))
index d8c91c4..21959e3 100644 (file)
@@ -2237,11 +2237,13 @@ class MainForm : Window
       imports.Free(FreeModuleImport);
 
       FreeGlobalData(globalData);
-      FreeTypeData(componentsApp);
       FreeIncludeFiles();
-      delete componentsApp;
+      if(componentsApp)
+      {
+         FreeTypeData(componentsApp);
+         delete componentsApp;
+      }
 
-      SetGlobalContext(globalContext);
       componentsApp = __ecere_COM_Initialize(false, 1, null);
       SetPrivateModule(componentsApp);
 
@@ -3863,12 +3865,11 @@ class Documentor : GuiApplication
    bool Init()
    {
       Platform os = __runtimePlatform;
-      componentsApp = __ecere_COM_Initialize(false, 1, null);
-      SetPrivateModule(componentsApp);
       SetGlobalContext(globalContext);
       SetExcludedSymbols(&excludedSymbols);
       SetDefines(&::defines);
       SetImports(&imports);
+      SetInDocumentor(true);
 
       SetGlobalData(globalData);