On 24/10/12 08:45, Rodolfo García Peñas wrote:
> Hi,
>
> yesterday I spent a lot of time with these problems. I need a bit help.
>
> My current installation is a bit "rare". I have some wmaker debian packages
> installed (at /usr) and the git code (at /usr/local), with my
> ~/GNUStep/Default/WindowMaker file configuration using both folders...
> Yesterday I was working in the icons part and I changed the code of
> get_default_image() to use the function get_rimage_from_file(). See the code
> below.
>
> But wmaker crash and crash when I called a application without icon (xcalc).
> Why? When I call xcalc, wmaker try to find the icon "HP-16C-48.xpm", the icon
> didn't exists and wmaker removes the icon from the Domain database and try to
> load "defaultAppIcon.tiff". Because my installation is not standard, wmaker
> didn't find "defaultAppIcon.tiff", then removes the icon from the Domain
> database and try to load again the default icon, BUT, now wmaker cannot find
> the icon in the Domain database because was just removed. This is the trace
> using the code below:
>
> wmaker(get_default_icon_filename(wdefaults.c:408)): warning: could not find
> icon file "HP-16C-48.xpm"
> dict 0xdb93f0
> value LPW
> file1 = defaultAppIcon.tiff
> wmaker(get_rimage_from_file(wdefaults.c:439)): warning: error loading image
> file "defaultAppIcon.tiff": could not open file
> image = (nil)
> file2 = defaultAppIcon.tiff
> wmaker(get_default_image(icon.c:662)): warning: could not load default icon
> "defaultAppIcon.tiff":could not open file
> dict 0xdb93f0
> value LPW
> file1 = Ȟf�
> wmaker(get_rimage_from_file(wdefaults.c:439)): warning: error loading image
> file "Ȟf": could not open file
> image = (nil)
> file2 = Ȟf�
>
> And, wmaker crash. Why? because IMO the code used to remove items from the
> HastTables (domain database) is wrong. It removes the item, but don't
> "removes the hole", then the next search in the hashtable, returns the item
> in the "hole", a memory "no-item" (trash, the " f"). The code is at
> WINGs/hashtable.c, functions WMHashRemove() and deleteFromList(). Help is
> very appreciated. Probably you can reproduce the problem renaming the
> defaultAppIcon.tiff image after wmaker is up and launching a application
> without icon (declare a non exist file in WMState file).
>
> On the other hand, I think that there is a problem in the icon load, because
> the icons exists:
>
> kix@osaka:~/src/wmaker/wmaker-crm/src$ find ~kix/GNUstep -name
> defaultAppIcon.tiff
> /home/kix/GNUstep/Library/Icons/defaultAppIcon.tiff
> kix@osaka:~/src/wmaker/wmaker-crm/src$ find /usr -name defaultAppIcon.tiff
> /usr/local/share/WindowMaker/Icons/defaultAppIcon.tiff
>
> But... wmaker is not including the full-path? Probably (I cannot check it),
> wmaker is trying to use the icon in the database. The database contains
> "GNUterm.tiff" and don't the full path... or probably I miss something.
>
> Help is very appreciated.
>
> Cheers,
> kix
>
>
>
> --- a/src/icon.c
> +++ b/src/icon.c
> @@ -644,25 +644,25 @@ static void get_pixmap_icon_from_default_icon(WIcon
> *icon
> static RImage *get_default_image(WScreen *scr)
> {
> RImage *image = NULL;
> - char *path, *file;
> + char *file = NULL;
>
> /* Get the default icon */
> file = wDefaultGetIconFile(NULL, NULL, True);
> - if (file) {
> - path = FindImage(wPreferences.icon_path, file);
> - if (path) {
> - image = RLoadImage(scr->rcontext, path, 0);
> - if (!image)
> - wwarning(_("could not load default icon
> \"%s\":
> - file, RMessageForError(RErrorCode));
> - wfree(path);
> - } else {
> - wwarning(_("could not find default icon \"%s\""),
> file)
> - }
> - }
>
> - /* Validate the icon size */
> - image = wIconValidateIconSize(image, wPreferences.icon_size);
> + printf("file1 = %s\n", file);
> +
> + /* If file is NULL, get_rimage_from_file returns NULL */
> + image = get_rimage_from_file(scr, file, wPreferences.icon_size);
> +
> + printf("image = %p\n", image);
> + printf("file2 = %s\n", file);
> +
> + if (file && !image)
> + wwarning(_("could not load default icon \"%s\":%s"),
> + file, RMessageForError(RErrorCode));
> +
> + if (file)
> + wfree(file);
>
Hi,
forget this mail. The problem was that I didn't call the FindImage() function,
then:
1. The full path for the icon was not found, therefore we don't have the icon.
2. I sent a wrong path file to get_rimage_from_file(), then the path exists,
but is wrong
The correct code is:
diff --git a/src/icon.c b/src/icon.c
index b4ccfc5..4b3e070 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -649,19 +649,14 @@ static RImage *get_default_image(WScreen *scr)
file = wDefaultGetIconFile(NULL, NULL, True);
if (file) {
path = FindImage(wPreferences.icon_path, file);
- if (path) {
- image = RLoadImage(scr->rcontext, path, 0);
- if (!image)
- wwarning(_("could not load default icon \"%s\":%
s"),
- file, RMessageForError(RErrorCode));
- wfree(path);
- } else {
+ if (path)
+ image = get_rimage_from_file(scr, path, wPreferences.ico
n_size);
+
+ if (!image)
wwarning(_("could not find default icon \"%s\""), file);
- }
- }
- /* Validate the icon size */
- image = wIconValidateIconSize(image, wPreferences.icon_size);
+ wfree(file);
+ }
return image;
}
--
1.7.10.4
I will sent the patches soon. Thanks Carlos for your help.
On the other hand, I would like my "roadmap" now. I will work the the
wIconUpdate() function. The problem is that wIconUpdate make two things:
1. Update the RImage file (the image itself) (and the image path char* if the
image was chose by the user) using the functions get_pixmap_icon_from_user_*
2. Updating the pixmap image, using the function makeImage() throw
get_pixmap_icon_from_user_* or directly using makeImage()
That is not correct. Why? For example, if we look the code at wmspec.c:
459 static void updateIconImage(WWindow *wwin)
460 {
461 /* Remove the icon image from X11 */
462 if (wwin->net_icon_image)
463 RReleaseImage(wwin->net_icon_image);
464
465 /* Save the icon in the X11 icon */
466 wwin->net_icon_image = get_wwindow_image_from_x11(wwin);
467
468 /* Refresh the Window Icon */
469 if (wwin->icon)
470 wIconUpdate(wwin->icon);
471
472 /* Refresh the application icon */
473 WApplication *app = wApplicationOf(wwin->main_window);
474 if (app && app->app_icon) {
475 wIconUpdate(app->app_icon->icon);
476 wAppIconPaint(app->app_icon);
477 }
478 }
This function updates the window image and application image using the image
provided by X11, after icon_update event send to the
Window Manager by X11.
But, if the image was selected by the user, the image provided by X11 is not
needed, so wIconUpdate is not needed. Now, the image is destroyed by
updateIconImage() and then wIconUpdate() creates the image again.
IMO is better to split the icon image update (step 1 above) and the pixmap
image update (step 2 above). We need call the pixmap image update only if the
icon image change.
The functions get_pixmap_icon_from_user_* needs return a Boolean value to know
if they update the icon or not.
Best regards,
kix
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
--
To unsubscribe, send mail to [email protected].