From ff58d04be4e8fed403a791736db05c76fa3adb65 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 18 Jul 2017 13:04:26 +0200 Subject: [PATCH] [dpkdir] restart VFS only for Map_Free() and Map_LoadFile(), refresh others Since there is no map file observer anymore for that stuff, we Restart or Refresh it explicitely when needed. - Opening map or New map needs Restarting VFS. - Saving map or Renaming map (Save as) needs Refreshing VFS. The Refresh also triggers the Texture browser. A previous fix for #105 was done Refreshing VFS instead of Restarting it but it was not perfect, for example map opening behavior is better with VFS restart, and map saving needs to refresh the VFS and the texture browser but not restart (that was the earlier fault). So, it's clearly not a good idea to trigger either Refresh or Restart on any map event since the behavior differs according to the event. If one day one plugin wants to act on VFS on map event, it must refresh or restart VFS according to what the plugin does. It does not make sense to trigger the same task for different events. --- radiant/mainframe.cpp | 4 +++- radiant/map.cpp | 19 ++++++++++++++++++- radiant/texwindow.cpp | 5 ++--- radiant/texwindow.h | 2 ++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 672b37ca..53ef24a6 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -116,7 +116,7 @@ #include "renderstate.h" #include "feedback.h" #include "referencecache.h" - +#include "texwindow.h" struct layout_globals_t @@ -166,6 +166,8 @@ void VFS_Refresh(){ QE_InitVFS(); GlobalFileSystem().refresh(); g_vfsInitialized = true; + // also refresh texture browser + TextureBrowser_RefreshShaders(); } void VFS_Restart(){ VFS_Shutdown(); diff --git a/radiant/map.cpp b/radiant/map.cpp index ed69f632..18d25c09 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -978,6 +978,10 @@ void Map_LoadFile( const char *filename ){ Map_StartPosition(); g_currentMap = &g_map; + + // restart VFS to apply new pak filtering based on mapname + // needed for daemon DPK VFS + VFS_Restart(); } class Excluder @@ -1186,6 +1190,9 @@ void Map_RenameAbsolute( const char* absolute ){ Map_UpdateTitle( g_map ); g_map.m_resource->attach( g_map ); + // refresh VFS to apply new pak filtering based on mapname + // needed for daemon DPK VFS + VFS_Refresh(); } void Map_Rename( const char* filename ){ @@ -1233,6 +1240,10 @@ void Map_New(){ FocusViews( g_vector3_identity, 0 ); g_currentMap = &g_map; + + // restart VFS to apply new pak filtering based on mapname + // needed for daemon DPK VFS + VFS_Restart(); } extern void ConstructRegionBrushes( scene::Node * brushes[6], const Vector3 ®ion_mins, const Vector3 ®ion_maxs ); @@ -1583,7 +1594,13 @@ tryDecompile: */ bool Map_SaveFile( const char* filename ){ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Saving Map" ); - return MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse, filename ); + bool success = MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse, filename ); + if ( success ) { + // refresh VFS to apply new pak filtering based on mapname + // needed for daemon DPK VFS + VFS_Refresh(); + } + return success; } // diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index e30f1035..c97044e3 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -2359,9 +2359,8 @@ void TextureBrowser_pasteTag(){ BuildStoreAvailableTags( g_TextureBrowser.m_available_store, g_TextureBrowser.m_assigned_store, g_TextureBrowser.m_all_tags, &g_TextureBrowser ); } -void RefreshShaders(){ +void TextureBrowser_RefreshShaders(){ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" ); - VFS_Refresh(); GlobalShaderSystem().refresh(); UpdateAllWindows(); GtkTreeSelection* selection = gtk_tree_view_get_selection((GtkTreeView*)GlobalTextureBrowser().m_treeViewTree); @@ -2567,7 +2566,7 @@ void TextureBrowser_Construct(){ GlobalCommands_insert( "DeleteTag", FreeCaller() ); GlobalCommands_insert( "CopyTag", FreeCaller() ); GlobalCommands_insert( "PasteTag", FreeCaller() ); - GlobalCommands_insert( "RefreshShaders", FreeCaller() ); + GlobalCommands_insert( "RefreshShaders", FreeCaller() ); GlobalToggles_insert( "ShowInUse", FreeCaller(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hideunused_item ), Accelerator( 'U' ) ); GlobalCommands_insert( "ShowAllTextures", FreeCaller(), Accelerator( 'A', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "ToggleTextures", FreeCaller(), Accelerator( 'T' ) ); diff --git a/radiant/texwindow.h b/radiant/texwindow.h index 3a872014..edc67b22 100644 --- a/radiant/texwindow.h +++ b/radiant/texwindow.h @@ -59,4 +59,6 @@ void TextureBrowser_setBackgroundColour( TextureBrowser& textureBrowser, const V void TextureBrowser_addActiveShadersChangedCallback( const SignalHandler& handler ); void TextureBrowser_addShadersRealiseCallback( const SignalHandler& handler ); +void TextureBrowser_RefreshShaders(); + #endif -- 2.39.2