remove const_cast hack and memory leak in 'load doubleclicked texture's directory'
This commit is contained in:
parent
339d078bc6
commit
f91df90d58
|
|
@ -1443,23 +1443,15 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event,
|
||||||
}
|
}
|
||||||
/* loads directory, containing active shader + focuses on it */
|
/* loads directory, containing active shader + focuses on it */
|
||||||
else if ( event->type == GDK_2BUTTON_PRESS && event->button == 1 && !TextureBrowser_showWads() ) {
|
else if ( event->type == GDK_2BUTTON_PRESS && event->button == 1 && !TextureBrowser_showWads() ) {
|
||||||
CopiedString texName = textureBrowser->shader;
|
const StringRange range( strchr( textureBrowser->shader.c_str(), '/' ) + 1, strrchr( textureBrowser->shader.c_str(), '/' ) + 1 );
|
||||||
char* sh = const_cast<char*>( texName.c_str() );
|
if( range.last - range.first != 0 ){
|
||||||
char* dir = strrchr( sh, '/' );
|
const CopiedString dir = range;
|
||||||
if( dir != NULL ){
|
ScopeDisableScreenUpdates disableScreenUpdates( dir.c_str(), "Loading Textures" );
|
||||||
*(dir + 1) = '\0';
|
TextureBrowser_ShowDirectory( *textureBrowser, dir.c_str() );
|
||||||
dir = strchr( sh, '/' );
|
|
||||||
if( dir != NULL ){
|
|
||||||
dir++;
|
|
||||||
if( *dir != '\0'){
|
|
||||||
ScopeDisableScreenUpdates disableScreenUpdates( dir, "Loading Textures" );
|
|
||||||
TextureBrowser_ShowDirectory( *textureBrowser, dir );
|
|
||||||
TextureBrowser_Focus( *textureBrowser, textureBrowser->shader.c_str() );
|
TextureBrowser_Focus( *textureBrowser, textureBrowser->shader.c_str() );
|
||||||
TextureBrowser_queueDraw( *textureBrowser );
|
TextureBrowser_queueDraw( *textureBrowser );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( event->type == GDK_2BUTTON_PRESS && event->button == 3 ) {
|
else if ( event->type == GDK_2BUTTON_PRESS && event->button == 3 ) {
|
||||||
ScopeDisableScreenUpdates disableScreenUpdates( TextureBrowser_getComonShadersDir(), "Loading Textures" );
|
ScopeDisableScreenUpdates disableScreenUpdates( TextureBrowser_getComonShadersDir(), "Loading Textures" );
|
||||||
TextureBrowser_ShowDirectory( *textureBrowser, TextureBrowser_getComonShadersDir() );
|
TextureBrowser_ShowDirectory( *textureBrowser, TextureBrowser_getComonShadersDir() );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user