Skip to content

Commit 1e96827

Browse files
feat: Add error handling for failed image loading in SetWindowIcon method
1 parent e3453ef commit 1e96827

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Core/Context.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ std::shared_ptr<Context> Context::GetInstance() {
163163

164164
void Context::SetWindowIcon(const std::string &path) {
165165
SDL_Surface *image = IMG_Load(path.c_str());
166-
SDL_SetWindowIcon(m_Window, image);
167-
SDL_FreeSurface(image);
166+
if (image) {
167+
SDL_SetWindowIcon(m_Window, image);
168+
SDL_FreeSurface(image);
169+
return;
170+
}
171+
LOG_ERROR("Failed to load image: {}", path);
168172
}
169173
} // namespace Core

0 commit comments

Comments
 (0)