Browse Source

Add flag for local or global opening of main lib

tags/1.9.8
falkTX 7 years ago
parent
commit
9ba7c439b4
4 changed files with 24 additions and 9 deletions
  1. +2
    -2
      source/carla_backend.py
  2. +2
    -2
      source/carla_backend_qt.py
  3. +18
    -5
      source/carla_host.py
  4. +2
    -0
      source/carla_shared.py

+ 2
- 2
source/carla_backend.py View File

@@ -2100,13 +2100,13 @@ class CarlaHostNull(CarlaHostMeta):
# Carla Host object using a DLL

class CarlaHostDLL(CarlaHostMeta):
def __init__(self, libName):
def __init__(self, libName, localLoad):
CarlaHostMeta.__init__(self)

# info about this host object
self.isPlugin = False

self.lib = CDLL(libName, RTLD_GLOBAL)
self.lib = CDLL(libName, RTLD_LOCAL if localLoad else RTLD_GLOBAL)

self.lib.carla_get_engine_driver_count.argtypes = None
self.lib.carla_get_engine_driver_count.restype = c_uint


+ 2
- 2
source/carla_backend_qt.py View File

@@ -91,9 +91,9 @@ class CarlaHostQtNull(CarlaHostNull, CarlaHostSignals):
# Carla Host object using a DLL

class CarlaHostQtDLL(CarlaHostDLL, CarlaHostSignals):
def __init__(self, libName):
def __init__(self, libName, localLoad):
CarlaHostSignals.__init__(self)
CarlaHostDLL.__init__(self, libName)
CarlaHostDLL.__init__(self, libName, localLoad)

# ------------------------------------------------------------------------------------------------------------
# Carla Host object for plugins (using pipes)


+ 18
- 5
source/carla_host.py View File

@@ -2325,6 +2325,16 @@ def fileCallback(ptr, action, isDir, title, filter):
def initHost(initName, libPrefix, isControl, isPlugin, failError, HostClass = None):
pathBinaries, pathResources = getPaths(libPrefix)

# --------------------------------------------------------------------------------------------------------
# Check if we should open main lib as local or global

settings = QSettings("falkTX", "Carla2")

try:
loadLocal = settings.value(CARLA_KEY_MAIN_LOAD_LIB_LOCAL, CARLA_DEFAULT_MAIN_LOAD_LIB_LOCAL, type=bool)
except:
loadLocal = CARLA_DEFAULT_MAIN_LOAD_LIB_LOCAL

# --------------------------------------------------------------------------------------------------------
# Fail if binary dir is not found

@@ -2337,8 +2347,9 @@ def initHost(initName, libPrefix, isControl, isPlugin, failError, HostClass = No
# --------------------------------------------------------------------------------------------------------
# Set Carla library name

libname = "libcarla_%s2.%s" % ("control" if isControl else "standalone", DLL_EXTENSION)
utilsname = "libcarla_utils.%s" % (DLL_EXTENSION)
libname = "libcarla_%s2.%s" % ("control" if isControl else "standalone", DLL_EXTENSION)
libname = os.path.join(pathBinaries, libname)
utilsname = os.path.join(pathBinaries, "libcarla_utils.%s" % (DLL_EXTENSION))

# --------------------------------------------------------------------------------------------------------
# Print info
@@ -2353,12 +2364,14 @@ def initHost(initName, libPrefix, isControl, isPlugin, failError, HostClass = No
# --------------------------------------------------------------------------------------------------------
# Init host



if failError:
# no try
host = HostClass() if HostClass is not None else CarlaHostQtDLL(os.path.join(pathBinaries, libname))
host = HostClass() if HostClass is not None else CarlaHostQtDLL(libname, loadLocal)
else:
try:
host = HostClass() if HostClass is not None else CarlaHostQtDLL(os.path.join(pathBinaries, libname))
host = HostClass() if HostClass is not None else CarlaHostQtDLL(libname, loadLocal)
except:
host = CarlaHostQtNull()

@@ -2381,7 +2394,7 @@ def initHost(initName, libPrefix, isControl, isPlugin, failError, HostClass = No
# --------------------------------------------------------------------------------------------------------
# Init utils

gCarla.utils = CarlaUtils(os.path.join(pathBinaries, utilsname))
gCarla.utils = CarlaUtils(utilsname)
gCarla.utils.set_process_name(os.path.basename(initName))

try:


+ 2
- 0
source/carla_shared.py View File

@@ -194,6 +194,7 @@ CARLA_KEY_MAIN_REFRESH_INTERVAL = "Main/RefreshInterval" # int
CARLA_KEY_MAIN_USE_CUSTOM_SKINS = "Main/UseCustomSkins" # bool
CARLA_KEY_MAIN_MANAGE_UIS = "Main/ManageUIs" # bool
CARLA_KEY_MAIN_SHOW_LOGS = "Main/ShowLogs" # bool
CARLA_KEY_MAIN_LOAD_LIB_LOCAL = "Main/LoadLibsLocal" # bool

CARLA_KEY_CANVAS_THEME = "Canvas/Theme" # str
CARLA_KEY_CANVAS_SIZE = "Canvas/Size" # str "NxN"
@@ -239,6 +240,7 @@ CARLA_DEFAULT_MAIN_REFRESH_INTERVAL = 20
CARLA_DEFAULT_MAIN_USE_CUSTOM_SKINS = True
CARLA_DEFAULT_MAIN_MANAGE_UIS = True
CARLA_DEFAULT_MAIN_SHOW_LOGS = bool(not WINDOWS)
CARLA_DEFAULT_MAIN_LOAD_LIB_LOCAL = True

# Canvas
CARLA_DEFAULT_CANVAS_THEME = "Modern Dark"


Loading…
Cancel
Save