From: Hosang Kim Date: Fri, 20 Oct 2023 06:57:40 +0000 (+0900) Subject: TizenDeviceImpl: fix thread safety X-Git-Tag: accepted/tizen/unified/20231024.032154^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6f8ab46d2cc6c4152a02a2d0e11e3038821a908;p=platform%2Fcore%2Fuifw%2Faurum.git TizenDeviceImpl: fix thread safety Remove static variable for thread safe Change-Id: I512484329c7c13e5c1bab56c6df3e73ea6bb94fe --- diff --git a/libaurum/inc/Impl/TizenDeviceImpl.h b/libaurum/inc/Impl/TizenDeviceImpl.h index df9970a..e62b7a6 100644 --- a/libaurum/inc/Impl/TizenDeviceImpl.h +++ b/libaurum/inc/Impl/TizenDeviceImpl.h @@ -200,7 +200,7 @@ private: * * @since_tizen 7.0 */ - std::vector> getTizenWindowInfo() const; + void getTizenWindowInfo(std::vector> &mTizenWindows) const; private: efl_util_inputgen_h mFakeTouchHandle; @@ -225,7 +225,6 @@ private: */ Size2D mScreenSize; static std::mutex CaptureMutex; - static std::vector> mTizenWindows; }; } diff --git a/libaurum/src/Impl/TizenDeviceImpl.cc b/libaurum/src/Impl/TizenDeviceImpl.cc index c99b130..47fc3b6 100644 --- a/libaurum/src/Impl/TizenDeviceImpl.cc +++ b/libaurum/src/Impl/TizenDeviceImpl.cc @@ -45,7 +45,6 @@ using namespace AurumInternal; #define WM_METHOD_NAME_INFO "GetVisibleWinInfo_v3" std::mutex TizenDeviceImpl::CaptureMutex = std::mutex{}; -std::vector> TizenDeviceImpl::mTizenWindows; static GDBusConnection *system_conn; TizenDeviceImpl::TizenDeviceImpl() @@ -442,7 +441,9 @@ bool TizenDeviceImpl::releaseTouchSeqNumber(int seq) std::vector> TizenDeviceImpl::getWindowRoot() const { LOGI("Request window info"); - getTizenWindowInfo(); + + std::vector> mTizenWindows{}; + getTizenWindowInfo(mTizenWindows); std::vector> ret{}; std::unordered_map> pidToAppNode{}; @@ -482,7 +483,7 @@ std::vector> TizenDeviceImpl::getWindowRoot() co return ret; } -std::vector> TizenDeviceImpl::getTizenWindowInfo() const +void TizenDeviceImpl::getTizenWindowInfo(std::vector> &mTizenWindows) const { GError *err = NULL; GDBusMessage *msg; @@ -507,14 +508,12 @@ std::vector> TizenDeviceImpl::getTizenWindowInfo() int layer; char *name; - mTizenWindows.clear(); - if (system_conn == NULL) { conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); if (conn == NULL) { LOGE("g_bus_get_sync() is failed. %s", err->message); g_error_free(err); - return mTizenWindows; + return; } system_conn = conn; } @@ -525,7 +524,7 @@ std::vector> TizenDeviceImpl::getTizenWindowInfo() WM_METHOD_NAME_INFO); if (msg == NULL) { LOGE("g_dbus_message_new_method_call() is failed."); - return mTizenWindows; + return; } reply = g_dbus_connection_send_message_with_reply_sync(system_conn, msg, @@ -584,6 +583,4 @@ out: g_object_unref(msg); if (reply) g_object_unref(reply); - - return mTizenWindows; }