44
55#include " tizen_app_manager_plugin.h"
66
7- #include < Ecore.h>
87#include < app.h>
98#include < flutter/event_channel.h>
109#include < flutter/event_sink.h>
1110#include < flutter/event_stream_handler.h>
1211#include < flutter/method_channel.h>
1312#include < flutter/plugin_registrar.h>
1413#include < flutter/standard_method_codec.h>
14+ #include < glib.h>
1515
1616#include < memory>
1717#include < optional>
@@ -256,8 +256,10 @@ class TizenAppManagerPlugin : public flutter::Plugin {
256256 void GetInstalledApps (std::unique_ptr<FlMethodResult> result) {
257257 // TizenAppManager::GetAllAppsInfo() is an expensive operation and might
258258 // cause unresponsiveness on low-end devices if run on the platform thread.
259- ecore_thread_run (
260- [](void *data, Ecore_Thread *thread) {
259+ GError *error = nullptr ;
260+ GThread *thread = g_thread_try_new (
261+ " flutter_tizen_plugins_tizen_app_manager_installed_appss" ,
262+ [](gpointer data) -> gpointer {
261263 auto *result = static_cast <FlMethodResult *>(data);
262264
263265 flutter::EncodableList list;
@@ -278,14 +280,22 @@ class TizenAppManagerPlugin : public flutter::Plugin {
278280 }
279281 result->Success (flutter::EncodableValue (list));
280282 delete result;
283+ return nullptr ;
281284 },
282- nullptr ,
283- [](void *data, Ecore_Thread *thread) {
284- auto *result = static_cast <FlMethodResult *>(data);
285- result->Error (" Operation failed" , " Failed to start a thread." );
286- delete result;
287- },
288- result.release ());
285+ result.get (), &error);
286+
287+ if (thread == nullptr ) {
288+ LOG_ERROR (" Failed to create a thread: %s" ,
289+ error ? error->message : " unknown error" );
290+ if (error) {
291+ g_error_free (error);
292+ }
293+ result->Error (" Operation failed" , " Failed to start a thread." );
294+ return ;
295+ }
296+
297+ result.release ();
298+ g_thread_unref (thread);
289299 }
290300
291301 void IsAppRunning (const flutter::EncodableMap *arguments,
0 commit comments