Skip to content

Commit

Permalink
#5634: Usability fixes: don't overwrite the shader clipboard if the m…
Browse files Browse the repository at this point in the history
…aterial is already matching,

otherwise we lose the texdef information of faces and patches.
  • Loading branch information
codereader committed Jun 11, 2021
1 parent b7587a4 commit 50c8993
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
20 changes: 16 additions & 4 deletions radiant/clipboard/ClipboardModule.cpp
Expand Up @@ -10,6 +10,19 @@
namespace ui
{

namespace
{
inline std::string getContentHash(const std::string& content)
{
// Inspect the clipboard when the main window regains focus
// and fire the event if the contents changed
math::Hash hash;
hash.addString(content);

return hash;
}
}

std::string ClipboardModule::getString()
{
std::string returnValue;
Expand Down Expand Up @@ -37,6 +50,8 @@ void ClipboardModule::setString(const std::string& str)
wxTheClipboard->SetData(new wxTextDataObject(str));
wxTheClipboard->Close();

_contentHash = getContentHash(str);

// Contents changed signal
_sigContentsChanged.emit();
}
Expand Down Expand Up @@ -77,10 +92,7 @@ void ClipboardModule::onAppActivated(wxActivateEvent& ev)
{
// Inspect the clipboard when the main window regains focus
// and fire the event if the contents changed
math::Hash hash;
hash.addString(getString());

std::string newHash = hash;
auto newHash = getContentHash(getString());

if (newHash != _contentHash)
{
Expand Down
8 changes: 7 additions & 1 deletion radiantcore/selection/clipboard/Clipboard.cpp
Expand Up @@ -88,7 +88,13 @@ void paste(const cmd::ArgumentList& args)
{
UndoableCommand undo("pasteMaterialFromClipboard");

GlobalShaderClipboard().setSourceShader(clipboardMaterial);
// Activate the material name in the shader clipboard, but don't overwrite
// anything there if the material is already matching to not overwrite Face/Patch information
if (GlobalShaderClipboard().getShaderName() != clipboardMaterial)
{
GlobalShaderClipboard().setSourceShader(clipboardMaterial);
}

algorithm::pasteShaderToSelection(args);
return;
}
Expand Down

0 comments on commit 50c8993

Please sign in to comment.