Unable to load icon image
-
My application (this is independent of Qt) provides a shell interface and this shell interface supports different types of commands. Some commands trigger launching of some GUI(which is QT based) . When user closes the GUI, control returns back to the shell interface.
2 kind of GUI, GUI1 and GUI2 can be launched with this use model. Depending on what command is used.
-
For GUI1, a different application is launched as a separate process and in current process a Qt event loop is launched to interact with the newly launched application. This internal Qt event loop stops when new application GUI is closed and once event loops stops control returns back to the shell
-
For GUI2 , a QMainWindow is created which among other things has some icons in its toolbar
Some commands trigger GUI1 and some GUI2
If commands are executed such that first GUI1 is launched and then its closed and then another command is run which launches GUI2. In this flow some images of icons in toolbar of QMainWindow of GUI2 are not loaded and they are blank. 2 out of 3 images are not loaded. One thing I noticed that icons that didnt load used gif and one that was loaded was a png image
Now if flow is such that GUI2 is launched first then all icon images load as expected.
Both times, icon path remains same and I am giving full image path to QIcon. I am not sure what is causing this behavior. Any suggestion on how to debug this?
-
-
My guess is that the imageformats plugin for gif is not loaded, on my system png doesn't rely on a plugin so that explains the different behavior.
You might want to check in which working directory is launched GUI2 in both cases.
Run your GUIs with theQT_DEBUG_PLUGINS
env variable set to have more info. -
Hi @GrecKo , Thank you for replying. I am running both from same directory. Only thing changes is the order of invocation.
I tried a run with QT_DEBUG_PLUGINS. It does seem something is idfferent between 2 runs wrt gif. In run where icon image is loaded successfully there are some prints about libqgif.so (like a warning about meta data found and at the end unload succeeded for libqgif.so) but in run in which icon image was not loaded properly such prints are not there.
Any idea why that might be the case? Build is same for both runs , only thing different is order of invocation. Is it that plugins are loaded if needed only during first invocation of QApplication. So if first invocation didnt use some plugin it wont be loaded when we load QApplication again in same session even if it was needed during second invocation.
I will read more about plugins in this context.
-
@abhic said in Unable to load icon image:
when we load QApplication again in same session
This may or may not be relevant. Are you saying the way your shell works when invoking GUI1/2 is to create a new
QApplication
object each time? And you destroy it after use each time. As opposed to allowing one instance ofQApplication
to persist and use it for each of GUI1/2 when wanted?Your code itself is not a plugin, right? (That was just @GrecKo asking about image formats plugin itself.)
-
Yes we create new QApplication each time and destroy it when GUI is closed. Is this not recommended?
Our code is not a plugin. We create QApplication from within shell executable.And it does seem qt plugin for gif (libqgif.so) is somehow not loading in the flow when GUI1 is launched first and it was loaded when GUI2 was run first
-
@abhic said in Unable to load icon image:
Yes we create new QApplication each time and destroy it when GUI is closed. Is this not recommended?
I don't know, but you are reporting "unusual" behaviour. If it's easy to change temporarily to persist the
QApplication
instance either from start up or first invocation across future requests it might be interesting to check whether that has any effect on observed behaviour.