- 论坛徽章:
- 0
|
请教这里的dx一个问题,用的gtk图形库,显示一个dialog,上面有个cancel按钮,用g_timeout_add后台进行文件的拷贝操作。
拷贝函数如下:
while (!feof(fs))
{
{
n = fread(buff, sizeof(char), sizeof(buff), fs);
if(n > 0 && errno != EINTR)
{
if(exit_copying)
{
if (*exit_copying)
{
remove(dest_full_path);
result = false;
goto CATCH;
}
}
m = fwrite(buff, sizeof(char), n, fd);
if (m <= 0 && errno == EINTR)
{
remove(dest_full_path);
result = false;
goto CATCH;
}
cnt++;
if(cnt > 100)
{
fflush(fd);
fsync(fileno(fd));
cnt = 0;
}
}
else
{
result = true;
goto CATCH;
}
}
}
如果cancel被按了,那么exit_copying就会被设置为true,那么照道理就会跳出这个循环,终止这个拷贝操作。
但是现在的问题是,这个循环不走玩,不会响应到ui上button的点击事件,没有机会设置exit_copying这个变量。
大家能不能给点建议! |
|