i have a problem (probably a logical one) from calling some procedures from a dll that are stored in the mainexe (small plugininterface). i use more than 100 procedures without problems but this xml stuff is makes my crazy
some code for testing purposes:
test.exe
Code: Select all
EnableExplicit
Structure uGWCoreOption
  sFile.s
  hXML.l
  hRootNode.l
  hMainNode.l
EndStructure
Define uGWCoreOption.uGWCoreOption
Procedure.b GWCoreOptionClose()
  Shared uGWCoreOption
  Protected bReturn.b = #False
  With uGWCoreOption
    If \hXML
      FreeXML(\hXML)
      \hXML = #Null
      \hRootNode = #Null
      \hMainNode = #Null
      bReturn = #True
    EndIf
  EndWith
  ProcedureReturn bReturn
EndProcedure
Procedure.b GWCoreOptionSave()
  Shared uGWCoreOption
  Protected bReturn.b = #False
  With uGWCoreOption
    If \hXML
      FormatXML(\hXML, #PB_XML_WindowsNewline | #PB_XML_ReduceNewline | #PB_XML_ReIndent)
      SaveXML(\hXML, \sFile, #PB_XML_StringFormat)
    EndIf
  EndWith
  ProcedureReturn bReturn
EndProcedure
Procedure.l GWCoreOptionInit()
  Shared uGWCoreOption
  With uGWCoreOption
    \sFile = "test.xml"
    \hXML = LoadXML(#PB_Any, \sFile, #PB_Unicode)
    If \hXML
      If XMLStatus(\hXML) = #PB_XML_Success
        \hRootNode = RootXMLNode(\hXML)
        \hMainNode = MainXMLNode(\hXML)
        If Not \hRootNode Or Not \hRootNode Or Not GetXMLNodeName(\hMainNode) = "gwcore"
          GWCoreOptionClose()
        EndIf
      Else
        GWCoreOptionClose()
      EndIf
    EndIf
    If Not \hXML
      DeleteFile(\sFile)
      \hXML = CreateXML(#PB_Any, #PB_Unicode)
      If \hXML
        \hRootNode = RootXMLNode(\hXML)
        \hMainNode = CreateXMLNode(\hRootNode)
        SetXMLNodeText(CreateXMLNode(\hRootNode, 0, #PB_XML_Comment), "gwcore preference file, manual editing can cause instability and crashes")
        SetXMLNodeName(\hMainNode, "gwcore")
        GWCoreOptionSave()
      EndIf
    EndIf
    ProcedureReturn \hXML
  EndWith
EndProcedure
Procedure.l GWCoreOptionGetModuleNode(sModule.s, bCreate.b = #False)
  Shared uGWCoreOption
  Protected lReturn.l = #Null, *lNode.l, lNode.l
  With uGWCoreOption
    If \hXML
      Repeat
        lNode + 1
        *lNode = XMLNodeFromPath(\hMainNode, "module[" + Str(lNode) + "]")
        If *lNode And GetXMLAttribute(*lNode, "name") = sModule
          lReturn = *lNode
          Break
        EndIf
      Until Not *lNode
      If Not lReturn And bCreate
        lReturn = CreateXMLNode(\hMainNode)
        SetXMLNodeName(lReturn, "module")
        SetXMLAttribute(lReturn, "name", sModule)
        GWCoreOptionSave()
      EndIf
    EndIf
  EndWith
  ProcedureReturn lReturn
EndProcedure
Procedure.b GWCoreOptionSetValueS(sModule.s, sName.s, sValue.s)
  Protected bReturn.b = #False, *lMainNode.l, *lNode.l
  *lMainNode = GWCoreOptionGetModuleNode(sModule)
  If *lMainNode
    *lNode = XMLNodeFromPath(*lMainNode, sName)
    If Not *lNode
      *lNode = CreateXMLNode(*lMainNode)
      SetXMLNodeName(*lNode, sName)
    EndIf
    If *lNode
      SetXMLNodeText(*lNode, sValue)
      GWCoreOptionSave()
      bReturn = #True
    EndIf
  EndIf
  ProcedureReturn bReturn
EndProcedure
GWCoreOptionInit()
OpenLibrary(0, "test.dll")
CallCFunction(0, "test", @GWCoreOptionSetValueS())
Delay(1000)
CloseLibrary(0)Code: Select all
Prototype.b GWCoreOptionSetValueS(sModule.s, sName.s, sValue.s)
Global GWCoreOptionSetValueS.GWCoreOptionSetValueS
EnableExplicit
Procedure Thread(lDummy.l)
  GWCoreOptionSetValueS("gwpp", "load", "true") ; <<< crash
EndProcedure
ProcedureDLL.l test(hProc.l)
  GWCoreOptionSetValueS = hProc
  
  ;CreateThread_(0, 0, @Thread(), 0, 0, 0)
  CreateThread(@Thread(), 0)
  ;GWCoreOptionSetValueS("gwpp", "load", "true") ; <<< works without problems
  Delay(100)
  ProcedureReturn #True
EndProcedurei hate errors (mostly logical failure) that i can not explain myself.
thanks for helping


