Setting Ecore events is separated from Init() method to prevent a crash issue.
If the ecore_wl2_shutdown() is called before app_terminate_cb() call,
the application will be crashed by that. While calling the ecore_wl2_shutdown(),
resources related to the wayland are released.
Currently, the indicator application has crashed when calling
the tzsh_indicator_service_destroy(). Because, it's released by the EcoreHandler::Fini().
The EcoreHandler::SetEvents() and the EcoreHandler::UnsetEvents() are added.
Change-Id: Ic153709518b24e4083688d1ccffb37e44c835a66
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
}
void AppCoreMultiWindowBase::Run(int argc, char** argv) {
- AppCoreBase::Run(argc, argv);
-}
-
-void AppCoreMultiWindowBase::Dispose() {
- for (auto& i : impl_->contexts_) {
- i->Exit();
- }
- impl_->contexts_.clear();
- impl_->factory_map_.clear();
- if (impl_->handler_.get() != nullptr)
- impl_->handler_->Fini();
- AppCoreBase::Dispose();
-}
-
-int AppCoreMultiWindowBase::OnCreate() {
- AppCoreBase::OnCreate();
-
class Trimmer : public EcoreHandler::ITrim {
public:
bool IsTrimmable() {
};
impl_->trim_ = std::unique_ptr<EcoreHandler::ITrim>(new Trimmer(this));
-
impl_->handler_ = std::make_shared<EcoreHandler>(this, impl_->trim_.get());
impl_->handler_->Init();
+
+ AppCoreBase::Run(argc, argv);
+}
+
+void AppCoreMultiWindowBase::Dispose() {
+ for (auto& i : impl_->contexts_) {
+ i->Exit();
+ }
+ impl_->contexts_.clear();
+ impl_->factory_map_.clear();
+ impl_->handler_->UnsetEvents();
+ AppCoreBase::Dispose();
+ impl_->handler_->Fini();
+}
+
+int AppCoreMultiWindowBase::OnCreate() {
+ impl_->handler_->SetEvents();
+ AppCoreBase::OnCreate();
return 0;
}
SetCoreUiDelegator(nullptr);
SetWindowDelegator(this);
impl_->plugin_delegator_.reset();
+
+ impl_->handler_->Init();
impl_->PluginInit(argc, argv);
char appid[PATH_MAX] = {0, };
if (ret != 0)
_E("Fail to get appid. pid(%d)", getpid());
- impl_->handler_->Init();
impl_->state_ = Impl::AS_NONE;
impl_->w_status_ = Impl::WS_NONE;
impl_->appid_ = std::string(appid);
}
void AppCoreUiBase::Dispose() {
- impl_->handler_->Fini();
+ impl_->handler_->UnsetEvents();
impl_->FiniWl();
impl_->appid_.clear();
AppCoreBase::Dispose();
impl_->PluginFini();
+ impl_->handler_->Fini();
}
std::unique_ptr<AppCoreTaskBase> AppCoreUiBase::CreateTask() {
}
int AppCoreUiBase::OnCreate() {
+ impl_->handler_->SetEvents();
AppCoreBase::OnCreate();
impl_->state_ = Impl::AS_CREATED;
LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]",
* limitations under the License.
*/
+#include <Ecore_Wl2.h>
#include <sys/types.h>
#include <unistd.h>
if (__builtin_expect(initialized_, 1))
return 0;
- dsp_ = wl_display_connect(nullptr);
+ auto* wl2_dsp = ecore_wl2_connected_display_get(nullptr);
+ if (wl2_dsp == nullptr)
+ wl2_dsp = ecore_wl2_display_connect(nullptr);
+
+ dsp_ = ecore_wl2_display_get(wl2_dsp);
if (dsp_ == nullptr) {
_E("wl_display_connect() is failed");
return -1;
reg_ = nullptr;
}
- if (dsp_) {
- wl_display_disconnect(dsp_);
- dsp_ = nullptr;
- }
-
+ dsp_ = nullptr;
initialized_ = false;
}
ecore_wl2_display_connect(nullptr);
traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
+ initialized_ = true;
+}
+
+void EcoreHandler::Fini() {
+ if (!initialized_)
+ return;
+
+ RemoveFlushTimer();
+
+ _E("Disconnect Wayland display");
+ ecore_wl2_display_disconnect(ecore_wl2_connected_display_get(nullptr));
+ ecore_wl2_shutdown();
+ initialized_ = false;
+}
+
+void EcoreHandler::SetEvents() {
hshow_ = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_SHOW,
StubShowCb, this);
if (hshow_ == nullptr)
StubAuxMessageCb, this);
if (hauxmsg_ == nullptr)
_E("Failed to add ECORE_WL2_EVENT_AUX_MESSAGE event");
-
- initialized_ = true;
}
-void EcoreHandler::Fini() {
- if (!initialized_)
- return;
-
- RemoveFlushTimer();
-
+void EcoreHandler::UnsetEvents() {
if (hshow_) {
ecore_event_handler_del(hshow_);
hshow_ = nullptr;
ecore_event_handler_del(hauxmsg_);
hauxmsg_ = nullptr;
}
-
- _E("Disconnect Wayland display");
- ecore_wl2_display_disconnect(ecore_wl2_connected_display_get(nullptr));
- ecore_wl2_shutdown();
- initialized_ = false;
}
void EcoreHandler::RaiseWin(unsigned int win_id) {
void Init();
void Fini();
+ void SetEvents();
+ void UnsetEvents();
void RaiseWin(unsigned int win_id);
void PauseWin(unsigned int win_id);
ITrim* GetTrim();