diff --git a/libs/os/path.h b/libs/os/path.h index 3e664afb..ff8a291c 100644 --- a/libs/os/path.h +++ b/libs/os/path.h @@ -232,19 +232,21 @@ DirectoryCleaned( const char* path ) : m_path( path ){ template TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const DirectoryCleaned& path ){ const char* i = path.m_path; - for (; *i != '\0'; ++i ) - { - if ( *i == '\\' ) { + if( !string_empty( i ) ){ + for (; *i != '\0'; ++i ) + { + if ( *i == '\\' ) { + ostream << '/'; + } + else + { + ostream << *i; + } + } + --i; + if ( *i != '/' && *i != '\\' ) { ostream << '/'; } - else - { - ostream << *i; - } - } - char c = *( i - 1 ); - if ( c != '/' && c != '\\' && !string_empty( path.m_path ) ) { - ostream << '/'; } return ostream; } diff --git a/radiant/modelwindow.cpp b/radiant/modelwindow.cpp index 757d1b2c..8dcf5647 100644 --- a/radiant/modelwindow.cpp +++ b/radiant/modelwindow.cpp @@ -1151,22 +1151,20 @@ public: // parse string of format *pathToLoad/depth*path2ToLoad/depth* // */depth* for root path ModelFolders( const char* pathsString ){ - char* str = strdup( pathsString ); - for( char* s = str; *s; ++s ) - if( *s == '\\' ) - *s = '/'; + StringOutputStream str( 128 ); + str << PathCleaned( pathsString ); - char* start = str; + const char* start = str.c_str(); while( 1 ){ while( *start == '*' ) ++start; - char* end = start; + const char* end = start; while( *end && *end != '*' ) ++end; if( start == end ) break; - char* slash = nullptr; - for( char* s = start; s != end; ++s ) + const char* slash = nullptr; + for( const char* s = start; s != end; ++s ) if( *s == '/' ) slash = s; if( slash != nullptr && end - slash > 1 ){ @@ -1178,7 +1176,6 @@ public: start = end; } - free( str ); if( m_modelFoldersMap.empty() ) m_modelFoldersMap.emplace( "models/", 99 ); } @@ -1314,7 +1311,7 @@ GtkWidget* ModelBrowser_constructWindow( GtkWindow* toplevel ){ gtk_table_attach( GTK_TABLE( table ), w, 2, 3, 0, 1, GTK_SHRINK, GTK_FILL, 0, 0 ); gtk_widget_show( w ); - GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( g_ModelBrowser.m_gl_scroll ) ); + GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( w ) ); g_signal_connect( G_OBJECT( vadjustment ), "value_changed", G_CALLBACK( ModelBrowser_scrollbarScroll ), &g_ModelBrowser ); } { // gl_widget