- opening the file selector was freeing a NULL pointer
[blender.git] / source / blender / editors / space_file / space_file.c
1 /**
2  * $Id:
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. 
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include <string.h>
30 #include <stdio.h>
31
32 #include "DNA_object_types.h"
33 #include "DNA_space_types.h"
34 #include "DNA_scene_types.h"
35 #include "DNA_screen_types.h"
36
37 #include "RNA_access.h"
38
39 #include "MEM_guardedalloc.h"
40
41 #include "BIF_gl.h"
42
43 #include "BLO_readfile.h"
44
45 #include "BLI_blenlib.h"
46 #include "BLI_arithb.h"
47 #include "BLI_rand.h"
48 #include "BLI_storage_types.h"
49
50 #include "BKE_colortools.h"
51 #include "BKE_context.h"
52 #include "BKE_screen.h"
53
54 #include "ED_space_api.h"
55 #include "ED_screen.h"
56 #include "ED_fileselect.h"
57
58 #include "IMB_imbuf_types.h"
59 #include "IMB_thumbs.h"
60
61 #include "WM_api.h"
62 #include "WM_types.h"
63
64 #include "UI_interface.h"
65 #include "UI_resources.h"
66 #include "UI_view2d.h"
67
68
69 #include "ED_markers.h"
70 #include "ED_fileselect.h"
71
72 #include "file_intern.h"        // own include
73 #include "fsmenu.h"
74 #include "filelist.h"
75
76 /* ******************** default callbacks for file space ***************** */
77
78 static SpaceLink *file_new(const bContext *C)
79 {
80         ARegion *ar;
81         SpaceFile *sfile;
82         
83         sfile= MEM_callocN(sizeof(SpaceFile), "initfile");
84         sfile->spacetype= SPACE_FILE;
85
86         /* header */
87         ar= MEM_callocN(sizeof(ARegion), "header for file");
88         BLI_addtail(&sfile->regionbase, ar);
89         ar->regiontype= RGN_TYPE_HEADER;
90         ar->alignment= RGN_ALIGN_TOP;
91
92         /* channel list region */
93         ar= MEM_callocN(sizeof(ARegion), "channel area for file");
94         BLI_addtail(&sfile->regionbase, ar);
95         ar->regiontype= RGN_TYPE_CHANNELS;
96         ar->alignment= RGN_ALIGN_LEFT;  
97
98         /* ui list region */
99         ar= MEM_callocN(sizeof(ARegion), "ui area for file");
100         BLI_addtail(&sfile->regionbase, ar);
101         ar->regiontype= RGN_TYPE_UI;
102         ar->alignment= RGN_ALIGN_TOP;
103
104         /* main area */
105         ar= MEM_callocN(sizeof(ARegion), "main area for file");
106         BLI_addtail(&sfile->regionbase, ar);
107         ar->regiontype= RGN_TYPE_WINDOW;
108         ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
109         ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
110         ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
111         ar->v2d.keeptot= V2D_KEEPTOT_STRICT;
112         ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
113
114         return (SpaceLink *)sfile;
115 }
116
117 /* not spacelink itself */
118 static void file_free(SpaceLink *sl)
119 {       
120         SpaceFile *sfile= (SpaceFile *) sl;
121         
122         if(sfile->files) {
123                 filelist_freelib(sfile->files);
124                 filelist_free(sfile->files);
125                 MEM_freeN(sfile->files);
126                 sfile->files= NULL;
127         }
128
129         if(sfile->folders_prev) {
130                 folderlist_free(sfile->folders_prev);
131                 MEM_freeN(sfile->folders_prev);
132                 sfile->folders_prev= NULL;
133         }
134
135         if(sfile->folders_next) {
136                 folderlist_free(sfile->folders_next);
137                 MEM_freeN(sfile->folders_next);
138                 sfile->folders_next= NULL;
139         }
140
141         if (sfile->params) {
142                 if(sfile->params->pupmenu)
143                         MEM_freeN(sfile->params->pupmenu);
144                 MEM_freeN(sfile->params);
145                 sfile->params= NULL;
146         }
147
148         if (sfile->layout) {
149                 MEM_freeN(sfile->layout);
150                 sfile->layout = NULL;
151         }
152 }
153
154
155 /* spacetype; init callback, area size changes, screen set, etc */
156 static void file_init(struct wmWindowManager *wm, ScrArea *sa)
157 {
158         SpaceFile *sfile= (SpaceFile*)sa->spacedata.first;
159         if(sfile->params) {
160                 MEM_freeN(sfile->params);
161                 sfile->params = 0;
162         }
163         printf("file_init\n");
164 }
165
166
167 static SpaceLink *file_duplicate(SpaceLink *sl)
168 {
169         SpaceFile *sfileo= (SpaceFile*)sl;
170         SpaceFile *sfilen= MEM_dupallocN(sl);
171         
172         /* clear or remove stuff from old */
173         sfilen->op = NULL; /* file window doesn't own operators */
174
175         if (sfileo->params)
176                 sfilen->files = filelist_new(sfileo->params->type);
177         if(sfileo->folders_prev)
178                 sfilen->folders_prev = MEM_dupallocN(sfileo->folders_prev);
179
180         if(sfileo->folders_next)
181                 sfilen->folders_next = MEM_dupallocN(sfileo->folders_next);
182
183         if(sfileo->params) {
184                 sfilen->params= MEM_dupallocN(sfileo->params);
185                 file_change_dir(sfilen);
186         }
187         if (sfileo->layout) {
188                 sfilen->layout= MEM_dupallocN(sfileo->layout);
189         }
190         return (SpaceLink *)sfilen;
191 }
192
193 static void file_refresh(const bContext *C, ScrArea *sa)
194 {
195         SpaceFile *sfile= CTX_wm_space_file(C);
196         FileSelectParams *params = ED_fileselect_get_params(sfile);
197
198         if (!sfile->folders_prev)
199                 sfile->folders_prev = folderlist_new();
200         if (!sfile->files) {
201                 sfile->files = filelist_new(params->type);
202                 file_change_dir(sfile);
203                 params->active_file = -1; // added this so it opens nicer (ton)
204         }
205         filelist_hidedot(sfile->files, params->flag & FILE_HIDE_DOT);
206         filelist_setfilter(sfile->files, params->flag & FILE_FILTER ? params->filter : 0);      
207         if (filelist_empty(sfile->files))
208         {
209                 filelist_readdir(sfile->files);
210         }
211         if(params->sort!=FILE_SORT_NONE) filelist_sort(sfile->files, params->sort);             
212         
213         if (params->renamefile[0] != '\0') {
214                 int idx = filelist_find(sfile->files, params->renamefile);
215                 if (idx >= 0) {
216                         struct direntry *file= filelist_file(sfile->files, idx);
217                         if (file) {
218                                 file->flags |= EDITING;
219                         }
220                 }
221                 params->renamefile[0] = '\0';
222         }
223         if (sfile->layout) sfile->layout->dirty= 1;
224
225 }
226
227 static void file_listener(ScrArea *sa, wmNotifier *wmn)
228 {
229         SpaceFile* sfile = (SpaceFile*)sa->spacedata.first;
230
231         /* context changes */
232         switch(wmn->category) {
233                 case NC_SPACE:
234                         switch (wmn->data) {
235                                 case ND_SPACE_FILE_LIST:
236                                         if (sfile->files) filelist_free(sfile->files);
237                                         ED_area_tag_refresh(sa);
238                                         ED_area_tag_redraw(sa);
239                                         break;
240                                 case ND_SPACE_FILE_PARAMS:
241                                         ED_area_tag_refresh(sa);
242                                         ED_area_tag_redraw(sa);
243                                         break;
244                         }
245                         break;
246         }
247 }
248
249 /* add handlers, stuff you only do once or on area/region changes */
250 static void file_main_area_init(wmWindowManager *wm, ARegion *ar)
251 {
252         ListBase *keymap;
253         
254         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
255         
256         /* own keymaps */
257         keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);
258         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
259
260         keymap= WM_keymap_listbase(wm, "FileMain", SPACE_FILE, 0);
261         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
262                                                            
263
264 }
265
266 static void file_main_area_listener(ARegion *ar, wmNotifier *wmn)
267 {
268         /* context changes */
269         switch(wmn->category) {
270                 case NC_SPACE:
271                         switch (wmn->data) {
272                                 case ND_SPACE_FILE_LIST:
273                                         ED_region_tag_redraw(ar);
274                                         break;
275                                 case ND_SPACE_FILE_PARAMS:
276                                         ED_region_tag_redraw(ar);
277                                         break;
278                         }
279                         break;
280         }
281 }
282
283 static void file_main_area_draw(const bContext *C, ARegion *ar)
284 {
285         /* draw entirely, view changes should be handled here */
286         SpaceFile *sfile= CTX_wm_space_file(C);
287         FileSelectParams *params = ED_fileselect_get_params(sfile);
288         FileLayout *layout=NULL;
289
290         View2D *v2d= &ar->v2d;
291         View2DScrollers *scrollers;
292         float col[3];
293
294         /* Needed, because filelist is not initialized on loading */
295         if (!sfile->files || filelist_empty(sfile->files))
296                 file_refresh(C, NULL);
297
298         layout = ED_fileselect_get_layout(sfile, ar);
299
300         /* clear and setup matrix */
301         UI_GetThemeColor3fv(TH_BACK, col);
302         glClearColor(col[0], col[1], col[2], 0.0);
303         glClear(GL_COLOR_BUFFER_BIT);
304         
305         /* Allow dynamically sliders to be set, saves notifiers etc. */
306         if (layout && (layout->flag == FILE_LAYOUT_VER)) {
307                 v2d->scroll = V2D_SCROLL_RIGHT;
308                 v2d->keepofs &= ~V2D_LOCKOFS_Y;
309                 v2d->keepofs |= V2D_LOCKOFS_X;
310         }
311         else {
312                 v2d->scroll = V2D_SCROLL_BOTTOM;
313                 v2d->keepofs &= ~V2D_LOCKOFS_X;
314                 v2d->keepofs |= V2D_LOCKOFS_Y;
315         }
316         /* v2d has initialized flag, so this call will only set the mask correct */
317         UI_view2d_region_reinit(v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
318
319         /* sets tile/border settings in sfile */
320         file_calc_previews(C, ar);
321
322         /* set view */
323         UI_view2d_view_ortho(C, v2d);
324         
325         /* on first read, find active file */
326         if (params->active_file == -1) {
327                 wmEvent *event= CTX_wm_window(C)->eventstate;
328                 file_hilight_set(sfile, ar, event->x, event->y);
329         }
330         
331         file_draw_list(C, ar);
332         
333         /* reset view matrix */
334         UI_view2d_view_restore(C);
335         
336         /* scrollers */
337         scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
338         UI_view2d_scrollers_draw(C, v2d, scrollers);
339         UI_view2d_scrollers_free(scrollers);
340
341 }
342
343 void file_operatortypes(void)
344 {
345         WM_operatortype_append(FILE_OT_select);
346         WM_operatortype_append(FILE_OT_select_all_toggle);
347         WM_operatortype_append(FILE_OT_select_border);
348         WM_operatortype_append(FILE_OT_select_bookmark);
349         WM_operatortype_append(FILE_OT_loadimages);
350         WM_operatortype_append(FILE_OT_highlight);
351         WM_operatortype_append(FILE_OT_execute);
352         WM_operatortype_append(FILE_OT_cancel);
353         WM_operatortype_append(FILE_OT_parent);
354         WM_operatortype_append(FILE_OT_previous);
355         WM_operatortype_append(FILE_OT_next);
356         WM_operatortype_append(FILE_OT_refresh);
357         WM_operatortype_append(FILE_OT_bookmark_toggle);
358         WM_operatortype_append(FILE_OT_add_bookmark);
359         WM_operatortype_append(FILE_OT_delete_bookmark);
360         WM_operatortype_append(FILE_OT_hidedot);
361         WM_operatortype_append(FILE_OT_filenum);
362         WM_operatortype_append(FILE_OT_directory_new);
363         WM_operatortype_append(FILE_OT_delete);
364         WM_operatortype_append(FILE_OT_rename);
365 }
366
367 /* NOTE: do not add .blend file reading on this level */
368 void file_keymap(struct wmWindowManager *wm)
369 {
370         wmKeymapItem *kmi;
371         /* keys for all areas */
372         ListBase *keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);
373         WM_keymap_add_item(keymap, "FILE_OT_bookmark_toggle", NKEY, KM_PRESS, 0, 0);
374         WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0);
375         WM_keymap_add_item(keymap, "FILE_OT_add_bookmark", BKEY, KM_PRESS, KM_CTRL, 0);
376         WM_keymap_add_item(keymap, "FILE_OT_hidedot", HKEY, KM_PRESS, 0, 0);
377         WM_keymap_add_item(keymap, "FILE_OT_previous", BACKSPACEKEY, KM_PRESS, 0, 0);
378         WM_keymap_add_item(keymap, "FILE_OT_next", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0);
379         WM_keymap_add_item(keymap, "FILE_OT_directory_new", IKEY, KM_PRESS, 0, 0);  /* XXX needs button */
380         WM_keymap_add_item(keymap, "FILE_OT_delete", XKEY, KM_PRESS, 0, 0);
381
382         /* keys for main area */
383         keymap= WM_keymap_listbase(wm, "FileMain", SPACE_FILE, 0);
384         WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_PRESS, 0, 0);
385         WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
386         WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0);
387         WM_keymap_add_item(keymap, "FILE_OT_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
388         WM_keymap_add_item(keymap, "FILE_OT_highlight", MOUSEMOVE, KM_ANY, 0, 0);
389         WM_keymap_add_item(keymap, "FILE_OT_loadimages", TIMER1, KM_ANY, KM_ANY, 0);
390         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
391         RNA_int_set(kmi->ptr, "increment", 1);
392         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0);
393         RNA_int_set(kmi->ptr, "increment", 10);
394         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
395         RNA_int_set(kmi->ptr, "increment", 100);
396         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, 0,0);
397         RNA_int_set(kmi->ptr, "increment", -1);
398         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_SHIFT, 0);
399         RNA_int_set(kmi->ptr, "increment", -10);
400         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0);
401         RNA_int_set(kmi->ptr, "increment",-100);
402         
403         /* keys for button area (top) */
404         keymap= WM_keymap_listbase(wm, "FileButtons", SPACE_FILE, 0);
405         WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
406         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
407         RNA_int_set(kmi->ptr, "increment", 1);
408         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0);
409         RNA_int_set(kmi->ptr, "increment", 10);
410         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
411         RNA_int_set(kmi->ptr, "increment", 100);
412         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, 0, 0);
413         RNA_int_set(kmi->ptr, "increment", -1);
414         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_SHIFT,0);
415         RNA_int_set(kmi->ptr, "increment", -10);
416         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL,0);
417         RNA_int_set(kmi->ptr, "increment",-100);
418 }
419
420
421 static void file_channel_area_init(wmWindowManager *wm, ARegion *ar)
422 {
423         ListBase *keymap;
424
425         ED_region_panels_init(wm, ar);
426
427         /* own keymaps */
428         keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);  
429         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
430 }
431
432 static void file_channel_area_draw(const bContext *C, ARegion *ar)
433 {
434         ED_region_panels(C, ar, 1, NULL, -1);
435 }
436
437 static void file_channel_area_listener(ARegion *ar, wmNotifier *wmn)
438 {
439         /* context changes */
440         switch(wmn->category) {
441                 
442         }
443 }
444
445 /* add handlers, stuff you only do once or on area/region changes */
446 static void file_header_area_init(wmWindowManager *wm, ARegion *ar)
447 {
448         ED_region_header_init(ar);
449 }
450
451 static void file_header_area_draw(const bContext *C, ARegion *ar)
452 {
453         ED_region_header(C, ar);
454 }
455
456 /* add handlers, stuff you only do once or on area/region changes */
457 static void file_ui_area_init(wmWindowManager *wm, ARegion *ar)
458 {
459         ListBase *keymap;
460
461         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
462
463         /* own keymap */
464         keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);  /* XXX weak? */
465         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
466
467         keymap= WM_keymap_listbase(wm, "FileButtons", SPACE_FILE, 0);   /* XXX weak? */
468         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
469 }
470
471 static void file_ui_area_draw(const bContext *C, ARegion *ar)
472 {
473         float col[3];
474         /* clear */
475         UI_GetThemeColor3fv(TH_PANEL, col);
476         glClearColor(col[0], col[1], col[2], 0.0);
477         glClear(GL_COLOR_BUFFER_BIT);
478
479         /* set view2d view matrix for scrolling (without scrollers) */
480         UI_view2d_view_ortho(C, &ar->v2d);
481
482         file_draw_buttons(C, ar);
483
484         UI_view2d_view_restore(C);
485 }
486
487 static void file_ui_area_listener(ARegion *ar, wmNotifier *wmn)
488 {
489         /* context changes */
490         switch(wmn->category) {
491                 case NC_SPACE:
492                         switch (wmn->data) {
493                                 case ND_SPACE_FILE_LIST:
494                                         ED_region_tag_redraw(ar);
495                                         break;
496                         }
497                         break;
498         }
499 }
500
501 /* only called once, from space/spacetypes.c */
502 void ED_spacetype_file(void)
503 {
504         SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype file");
505         ARegionType *art;
506         
507         st->spaceid= SPACE_FILE;
508         
509         st->new= file_new;
510         st->free= file_free;
511         st->init= file_init;
512         st->duplicate= file_duplicate;
513         st->refresh= file_refresh;
514         st->listener= file_listener;
515         st->operatortypes= file_operatortypes;
516         st->keymap= file_keymap;
517         
518         /* regions: main window */
519         art= MEM_callocN(sizeof(ARegionType), "spacetype file region");
520         art->regionid = RGN_TYPE_WINDOW;
521         art->init= file_main_area_init;
522         art->draw= file_main_area_draw;
523         art->listener= file_main_area_listener;
524         art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
525         BLI_addhead(&st->regiontypes, art);
526         
527         /* regions: header */
528         art= MEM_callocN(sizeof(ARegionType), "spacetype file region");
529         art->regionid = RGN_TYPE_HEADER;
530         art->minsizey= HEADERY;
531         art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
532         art->init= file_header_area_init;
533         art->draw= file_header_area_draw;
534         // art->listener= file_header_area_listener;
535         BLI_addhead(&st->regiontypes, art);
536         
537         /* regions: ui */
538         art= MEM_callocN(sizeof(ARegionType), "spacetype file region");
539         art->regionid = RGN_TYPE_UI;
540         art->minsizey= 60;
541         art->keymapflag= ED_KEYMAP_UI;
542         art->listener= file_ui_area_listener;
543         art->init= file_ui_area_init;
544         art->draw= file_ui_area_draw;
545         BLI_addhead(&st->regiontypes, art);
546
547         /* regions: channels (directories) */
548         art= MEM_callocN(sizeof(ARegionType), "spacetype file region");
549         art->regionid = RGN_TYPE_CHANNELS;
550         art->minsizex= 240;
551         art->keymapflag= ED_KEYMAP_UI;
552         art->listener= file_channel_area_listener;
553         art->init= file_channel_area_init;
554         art->draw= file_channel_area_draw;
555         BLI_addhead(&st->regiontypes, art);
556         file_panels_register(art);
557
558         BKE_spacetype_register(st);
559
560 }
561
562 void ED_file_init(void)
563 {
564         char name[FILE_MAX];
565         BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
566         fsmenu_read_file(fsmenu_get(), name);
567         filelist_init_icons();
568         IMB_thumb_makedirs();
569 }
570
571 void ED_file_exit(void)
572 {
573         fsmenu_free(fsmenu_get());
574         filelist_free_icons();
575 }