1

I'm working on software which downloads a file and shows transfer speed via an SDL window. My problem is that when I launch a download, the window is immediately identified by windows as a crashed program. As soon as the download is completed, everything is okay. My program didn't crash and I think that it's because it can't respond when it's downloading. Any ideas how to solve that?

PS: example of code which 'crashes' when performed:

curl_easy_setopt(curl, CURLOPT_URL, valeurs->URL);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, downloadData);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
Taiki
  • 629
  • 5
  • 13
  • 1
    Perhaps you can perform your download in a separate thread and occasionally poll the download for progress? – Bart Nov 19 '11 at 22:49
  • How do you mean "identified by windows as a crashed program"? – Cyclonecode Nov 19 '11 at 22:50
  • 2
    @KristerAndersson I think he means the standard "application does not respond"-type behavior with the window changing color. – Bart Nov 19 '11 at 22:53
  • @Bart: I actually use a thread, the other part of the programm run code but still identified like crashed. By crashed, i mean the window changing color and if the user click inside, a window pop up for close the programm = – Taiki Nov 19 '11 at 23:09
  • BTW, curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, downloadData); run code in downloadData() several times/second and i receive datas generated by this function :| – Taiki Nov 19 '11 at 23:21
  • After performed some tests, I've new fact. The issue is linked with SDL: my code without SDL work perfect but as soon as I add SDL, the freeze happen – Taiki Nov 22 '11 at 17:14

1 Answers1

1

To prevent those freeze, you need to put, in the main thread an event manager (SDL_PoolEvent + SDL_Delay to not overuse CPU)

Taiki
  • 629
  • 5
  • 13