}
// return current process id
-pid_t _getpid()
+static pid_t _getpid()
{
if (gPid == -1)
gPid = getpid();
}
// return current thread id
-pid_t _gettid()
+static pid_t _gettid()
{
if(gTid == -1)
gTid = syscall(__NR_gettid); // syscall is very expensive
msg_send(APP_MSG_GET_UI_SCREENSHOT, buf, sizeof(buf));
}
+static bool make_screenshot_path(char *buf, size_t size)
+{
+ static int index = 0;
+ int n;
+
+ __atomic_fetch_add(&index, 1, __ATOMIC_SEQ_CST);
+ n = snprintf(buf, size, TMP_DIR "/ui_screenshot_%d_%d.png",
+ _getpid(), index);
+ if (n < 0) {
+ PRINTERR("Cannot create path, an output error occurred");
+ return false;
+ } else if ((size_t)n >= size) {
+ PRINTERR("Cannot create path, buffer is very small");
+ return false;
+ }
+
+ return true;
+}
+
bool print_log_ui_obj_screenshot(Evas_Object *obj)
{
int ret = -1;
enum ErrorCode err;
char path[PATH_MAX];
+ if (!make_screenshot_path(path, sizeof(path))) {
+ PRINTERR("Cannot create screenshot path");
+ return false;
+ }
+
err = ui_obj_screenshot(obj, path);
if (err == ERR_NO) {
ret = screenshot_send_to_socket(path);