Opened 5 years ago

Closed 4 years ago

Last modified 2 years ago

#11146 closed defect (fixed)

Assert in wxTopLevelWindowMSW::SetIcons()

Reported by: troelsk Owned by:
Priority: normal Milestone: 2.9.1
Component: wxMSW Version: stable-latest
Keywords: wxTopLevelWindow SetIcons Cc: vaclavslavik
Blocked By: Blocking:
Patch: no

Description

"icon bundle doesn't contain any suitable icon".
The assert is shown when running the dialogs sample (or similar user code).
I don't know why.

Change History (12)

comment:1 Changed 5 years ago by vadz

  • Status changed from new to infoneeded_new

This doesn't happen here, are you using non-default icon sizes somehow?

Could you please test what goes on inside DoSelectAndSetIcon() calls? They really should succeed...

comment:2 Changed 5 years ago by troelsk

  • Status changed from infoneeded_new to new

dialogs sample: both calls to DoSelectAndSetIcon/GetIconOfExactSize fails.
widgets sample: first call to DoSelectAndSetIcon/GetIconOfExactSize fails, second call ok.

Vista SP2, using 120 dpi fonts. Don't know if the icon size is unusual, I can't find the setting!

comment:3 Changed 5 years ago by vadz

Really strange, I don't understand why would this happen. Can anyone else reproduce this assert in the dialogs sample? The only strange thing I see about it is that its 32 pixel icon seems to be empty, could this be the source of the problem?

For the icon size, what is the value of size in the beginning of DoSelectAndSetIcon() in your case? Normally it is supposed to be 16x16 and 32x32.

comment:4 Changed 5 years ago by troelsk

Sizes are 22x22 and 40x40. The latter succeeds in the widgets sample.

comment:5 Changed 5 years ago by vadz

  • Cc vaclavslavik added

I don't understand neither why do the sizes have such strange values nor why does it succeed to convert 32*32 icon to 40*40 but not 16*16 one to 22*22. Right now this is a total mystery for me and I don't know how should we deal with this at wx API level. We intentionally didn't want to use icons of size different from the one used by the system because scaling such small icons is really ugly but it seems unavoidable as I don't see how can you have all your icons in 16*16, 22*22, 32*32, 40*40, 64*64 &c formats.

comment:6 Changed 5 years ago by troelsk

scaling such small icons is really ugly but it seems unavoidable

Indeed. On this particular Lenovo laptop with Vista preinstalled I see fairly ugly scaled icons, esp Daemon Tools in the tray is obviously scaled in this way, ugly looking.

  • Very strange that [only] the widgets sample manages to get through DoSelectAndSetIcon/GetIconOfExactSize successfully.

comment:7 Changed 5 years ago by vadz

  • Milestone set to 2.9.1

Practically speaking I think we should restrict the assert to 16*16 and 32*32 icons. The programmer can't be expected to prepare the icons in any other sizes anyhow so scaling seems inevitable if they're used for whatever (as of now mysterious) reason.

Vaclav, any objections?

comment:8 Changed 4 years ago by vadz

I think the problem is due to the fact that dialogs sample uses an invalid/empty 32*32 icon. If both 16*16 and 32*32 icons are available, the assert doesn't happen. So this is not really a problem with the code in SetIcons() itself and will be fixed by simply using the sample sample.ico for the dialogs sample as we already use for most of the other samples.

comment:9 Changed 4 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [64645]) Remove unnecessary mondrian.{ico,xpm} files from samples directory.

Standardize on using sample.rc and sample icon in all the samples, it was
confusing that some of them used it and other didn't, without any apparent
logic.

Remove the now unnecessary icon files, including the dialogs sample icon which
seemed to be corrupted (this closes #11146).

Also replace multiple OS/2 resource files with a single one in the sample
directory. The OS/2 projects/makefiles would need to be updated to use them.

Remove dialogs sample icon.

comment:10 Changed 4 years ago by VZ

(In [65084]) Remove asserts in wxMSW::wxTLW::SetIcons() and always set some icon.

In practice having the icons of the exact size for all versions of Windows is
not always possible, there are just too many of them. So set the icon of the
most suitable size if no exact match is found instead of asserting in this
case.

See #11146.

comment:11 follow-up: Changed 3 years ago by ngpaton

Note that at least on Win7 selecting an icon of a larger size than the required size produces slightly better results.

comment:12 in reply to: ↑ 11 Changed 2 years ago by disc

Replying to ngpaton:

Note that at least on Win7 selecting an icon of a larger size than the required size produces slightly better results.

This is handled in #13891 and implemented in r70455.

Note: See TracTickets for help on using tickets.