Linux: Fix crash using Aseprite in batch mode

Reported here:
http://steamcommunity.com/app/431730/discussions/2/1499000547480220354/
This commit is contained in:
David Capello 2017-12-11 13:40:26 -03:00
parent 31bf851d4f
commit 4c9e67de18
2 changed files with 30 additions and 26 deletions

View File

@ -231,38 +231,39 @@ void App::initialize(const AppOptions& options)
}
she::instance()->finishLaunching();
#if !defined(_WIN32) && !defined(__APPLE__)
try {
she::Display* display = she::instance()->defaultDisplay();
she::SurfaceList icons;
for (const int size : { 32, 64, 128 }) {
ResourceFinder rf;
rf.includeDataDir(fmt::format("icons/ase{0}.png", size).c_str());
if (rf.findFirst()) {
she::Surface* surf = she::instance()->loadRgbaSurface(rf.filename().c_str());
if (surf)
icons.push_back(surf);
}
}
display->setIcons(icons);
for (auto surf : icons)
surf->dispose();
}
catch (const std::exception&) {
// Just ignore the exception, we couldn't change the app icon, no
// big deal.
}
#endif
}
void App::run()
{
// Run the GUI
if (isGui()) {
#if !defined(_WIN32) && !defined(__APPLE__)
// Setup app icon for Linux window managers
try {
she::Display* display = she::instance()->defaultDisplay();
she::SurfaceList icons;
for (const int size : { 32, 64, 128 }) {
ResourceFinder rf;
rf.includeDataDir(fmt::format("icons/ase{0}.png", size).c_str());
if (rf.findFirst()) {
she::Surface* surf = she::instance()->loadRgbaSurface(rf.filename().c_str());
if (surf)
icons.push_back(surf);
}
}
display->setIcons(icons);
for (auto surf : icons)
surf->dispose();
}
catch (const std::exception&) {
// Just ignore the exception, we couldn't change the app icon, no
// big deal.
}
#endif
// Initialize Steam API
#ifdef ENABLE_STEAM
steam::SteamAPI steam;

View File

@ -537,6 +537,9 @@ void Alleg4Display::setIcons(const SurfaceList& icons)
{
#ifdef ALLEGRO_UNIX
if (!_xwin.display || !_xwin.wm_window)
return;
bool first = true;
for (Surface* icon : icons) {
auto display = _xwin.display;