DC-SWAT Forum
SDL_FreeSurface ? - Версия для печати

+- DC-SWAT Forum (http://www.dc-swat.ru/forum)
+-- Форум: DreamShell (/forum-3.html)
+--- Форум: Programming (/forum-28.html)
+--- Тема: SDL_FreeSurface ? (/thread-1732.html)



SDL_FreeSurface ? - superdefault - 01.11.2011 12:56

i still got problems getting my isoBrowser app to work.
at least i made some progress: i am pretty sure now that i fill up the ram with all the button instances i create until the app freezes.

so my question is: how to free up some ram again?
i create buttons and load images into my buttons like:

b = DS.GUI_ButtonCreate(.....);
s = DS.GUI_SurfaceLoad(self.currentpath .. appname .. "/icon.jpg");
DS.GUI_ButtonSetNormalImage(b, s);
...etc...

then i add the button to a container named 'panel' on the screen:
DS.GUI_ContainerAdd(self.apps.panel, b);

this works well.

but i got NO IDEA how to free the ram i used for loading the images.
can anyone point me to the right direction here?
is there a way to "DS.SDL_FreeSurface( s );" somehow ?

"GUI_ContainerRemove" removes the container but doesn't free the ram right?
"GUI_WidgetErase" ?
"GUI_WidgetUpdate" ?

i am lost in endless loops of trial and error. Confused
any help is highly appreciated!!


RE: SDL_FreeSurface ? - SWAT - 01.11.2011 13:30

DS.GUI_ContainerAdd(self.apps.panel, b);
DS.GUI_ObjectDecRef(DS.GUI_AnyToObject(b));

Then if you call GUI_ContainerRemove, widget deleted from memory.


RE: SDL_FreeSurface ? - superdefault - 01.11.2011 13:40

whoa that was FAST!
i'll try this asap!
thank you VERY MUCH,good sir! Smile


RE: SDL_FreeSurface ? - superdefault - 01.11.2011 20:36

dammmn. no luck here....

if i do it like this:
DS.GUI_ContainerAdd(self.apps.panel, b);
DS.GUI_ObjectDecRef(DS.GUI_AnyToObject(b));

the app won't even start and freezes the loading screen.
without DS.GUI_ObjectDecRef(DS.GUI_AnyToObject(b));
the app starts again.

b is definitely a button.
GUI_ContainerAdd adds it to the screen.
so nothing wrong there i'd say.

what could be the reason for DS.GUI_ObjectDecRef to freeze everything even BEFORE it is called?

EDIT: i am testing on nullDC. if that matters...


RE: SDL_FreeSurface ? - SWAT - 02.11.2011 07:05

Yes, unfortunately I ran into the same problem and so far can not fix it Sad
In C, it works ...
You need to find another solution can not necessarily delete and create the button every time? Maybe its just a one time set up and use with different callbacks?

I would recommend you, move your application logic in a module, it will solve the problems with memory.


RE: SDL_FreeSurface ? - superdefault - 02.11.2011 13:20

thanks again for your reply!
i'll think about another solution. it would be possible to create the buttons once and just update them with new callbacks, although.. i'd like to give every button it's own icon, and thats going to fill up the ram again, right?

i will give the module a try. that's probably too much for a script kiddie like me, but i'll give it a shot..

thanks for your time!


RE: SDL_FreeSurface ? - SWAT - 03.11.2011 07:22

I will help you with the module.


RE: SDL_FreeSurface ? - superdefault - 03.11.2011 19:16

(03.11.2011 07:22)SWAT писал(а):  I will help you with the module.

Awesome!
i will clean up my code, take a look at the module sdk and let you know when/where i get stuck?
thank again!


RE: SDL_FreeSurface ? - SWAT - 04.11.2011 09:16

I'm even more to say. I will propose to include your application in a new version of the DS, combining it with my application, it is still not completed yet. It would have saved me time and you do not have to rewrite the application for the new version of DS.


RE: SDL_FreeSurface ? - superdefault - 06.11.2011 17:19

sounds even more awesome!
in this case i am going to refine the design as well!

so what works best for you: do you want me to try getting my app into a module? or do you want the cleaned up sources and port it yourself?


RE: SDL_FreeSurface ? - SWAT - 06.11.2011 19:29

You can start writing the module, and later I'll give you a new SDK and the latest build of DS for the tests.


RE: SDL_FreeSurface ? - superdefault - 10.11.2011 22:43

sorry for the delay. i am super busy with something else until sunday.
looking forward to some free time next week..!


RE: SDL_FreeSurface ? - SWAT - 11.11.2011 09:26

It's okay, I understand you Smile


RE: SDL_FreeSurface ? - superdefault - 15.11.2011 13:34

alright.back at it.

i wasted some time to get an environment up and running on os x.
i will get back to that later.

for now i got everything running on my bootcamps windows. the test module from your sdk compiles fine.
now i got one or two questions about the module in general..
i'll PM you later- after work........................


RE: SDL_FreeSurface ? - superdefault - 17.11.2011 14:22

got a couple of things working now and i start to get an idea how to build the module!
man...debugging is so comfortable now within cygwin! really nice..!


RE: SDL_FreeSurface ? - SWAT - 17.11.2011 17:48

Glad to hear it Smile