Skip to content

Commit

Permalink
Fix crash upon creating an animated texture from the root directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamyCecil committed Nov 11, 2023
1 parent 27b8bff commit 80cf095
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Sources/EngineGui/DlgCreateAnimatedTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,16 @@ void CDlgCreateAnimatedTexture::OnCreateTexture()
if( m_strCreatedTextureName == "Unnamed")
{
// extract last sub directory name
char achrLastSubDir[ 256];
strcpy(achrLastSubDir, m_fnSourceFileName.FileDir().ConstData());
achrLastSubDir[ strlen(achrLastSubDir)-1]=0; // remove last '\'
CTString strLastSubDir = CTFileName(CTString(achrLastSubDir)).FileName();
CTString strLastSubDir = m_fnSourceFileName.FileDir();

// [Cecil] Avoid the crash if the directory is empty (i.e. root directory)
if (strLastSubDir == "") {
strLastSubDir = "Texture";

} else {
strLastSubDir.Data()[strLastSubDir.Length() - 1] = '\0'; // Remove last '\'
strLastSubDir = strLastSubDir.FileName();
}

// call save texture requester
fnSaveName = _EngineGUI.BrowseTexture(
Expand Down

0 comments on commit 80cf095

Please sign in to comment.