Skip to content

Commit

Permalink
fix(packages): fix crash issue when running device-api
Browse files Browse the repository at this point in the history
 - include coding style modifications

Signed-off-by: Hosung Kim [email protected]
  • Loading branch information
hs0225 authored and daeyeon committed Mar 26, 2024
1 parent 70275f5 commit a5b1444
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
29 changes: 11 additions & 18 deletions modules/packages/device-api/src/TizenDeviceAPILoaderForEscargot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ void printArguments(ContextRef* context, size_t argc, ValueRef** argv)

void* ExtensionManagerInstance::operator new(size_t size)
{



static bool typeInited = false;
static GC_descr descr;
if (!typeInited) {
Expand Down Expand Up @@ -98,30 +95,25 @@ void* ExtensionManagerInstance::operator new(size_t size)
wrt::xwalk::Extension* ExtensionManagerInstance::getExtension(
const char* apiName)
{
DEVICEAPI_LOG_INFO("Creating a new extension: %s\n", apiName);

auto extensionManager = wrt::xwalk::ExtensionManager::GetInstance();
wrt::xwalk::ExtensionMap& extensions = extensionManager->extensions();

const char* extensionsDirPath = "/usr/lib/tizen-extensions-crosswalk";
auto it = extensions.find(apiName);
if (it == extensions.end()) {
DEVICEAPI_LOG_INFO("Enter");
DEVICEAPI_LOG_INFO("Creating a new extension: %s\n", apiName);
char library_path[512];
if (!strcmp(apiName, "tizen")) {
snprintf(library_path, 512,
"/usr/lib/tizen-extensions-crosswalk/libtizen.so");
snprintf(library_path, 512, "%s/libtizen.so", extensionsDirPath);
} else if (!strcmp(apiName, "sensorservice")) {
snprintf(library_path, 512,
"/usr/lib/tizen-extensions-crosswalk/libtizen_sensor.so");
snprintf(library_path, 512, "%s/libtizen_sensor.so", extensionsDirPath);
} else if (!strcmp(apiName, "sa")) {
snprintf(library_path, 512,
"/usr/lib/tizen-extensions-crosswalk/libwebapis_sa.so");
snprintf(library_path, 512, "%s/libwebapis_sa.so", extensionsDirPath);
} else if (!strcmp(apiName, "tvaudiocontrol")) {
snprintf(library_path, 512,
"/usr/lib/tizen-extensions-crosswalk/libtizen_tvaudio.so");
snprintf(library_path, 512, "%s/libtizen_tvaudio.so", extensionsDirPath);
} else {
snprintf(library_path, 512,
"/usr/lib/tizen-extensions-crosswalk/libtizen_%s.so",
apiName);
snprintf(library_path, 512, "%s/libtizen_%s.so", extensionsDirPath, apiName);
}

wrt::xwalk::Extension* extension =
Expand All @@ -136,6 +128,7 @@ wrt::xwalk::Extension* ExtensionManagerInstance::getExtension(
return nullptr;
}
} else {
DEVICEAPI_LOG_INFO("Load extension: %s\n", apiName);
return it->second;
}
}
Expand Down Expand Up @@ -881,9 +874,9 @@ ExtensionManagerInstance::~ExtensionManagerInstance()
std::lock_guard<std::mutex> guard(s_mutex);
DEVICEAPI_LOG_INFO(
"ExtensionManagerInstance delete ExtensionManagerInstance %p", this);
for (auto it : m_extensionInstances)
for (auto& it : m_extensionInstances)
delete it.second;
for (auto it : m_postListeners)
for (auto& it : m_postListeners)
it->finalize();
auto it = s_extensionManagerInstances.find(m_context);
s_extensionManagerInstances.erase(it);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ class ExtensionManagerInstance : public gc {
#undef DECLARE_TIZEN_OBJECT

// static members
typedef std::map<Escargot::ContextRef*, ExtensionManagerInstance*>
typedef std::map<Escargot::ContextRef*,
Escargot::PersistentRefHolder<ExtensionManagerInstance>>
ExtensionManagerInstanceMap;
static ExtensionManagerInstanceMap s_extensionManagerInstances;
static std::mutex s_mutex;
Expand Down

0 comments on commit a5b1444

Please sign in to comment.