Fix: Broken active highlighting of assets in the asset shelf
Suspecting a mismatch when asset weak references stored using Unix style paths with ones generated at runtime with Windows sytle paths. Pull Request: https://projects.blender.org/blender/blender/pulls/124415
This commit is contained in:
committed by
Julian Eisel
parent
57f1d959d4
commit
46c0d3e644
@@ -132,6 +132,35 @@ TEST_F(AssetRepresentationTest, weak_reference__compare)
|
||||
other.relative_asset_identifier = "path/to/an/asset";
|
||||
EXPECT_EQ(weak_ref, other);
|
||||
|
||||
other.relative_asset_identifier = "";
|
||||
EXPECT_NE(weak_ref, other);
|
||||
other.relative_asset_identifier = nullptr;
|
||||
EXPECT_NE(weak_ref, other);
|
||||
|
||||
/* Make the destructor work. */
|
||||
other.asset_library_identifier = nullptr;
|
||||
other.relative_asset_identifier = nullptr;
|
||||
}
|
||||
|
||||
/* Same but comparing windows and unix style paths. */
|
||||
{
|
||||
AssetLibraryService *service = AssetLibraryService::get();
|
||||
AssetLibrary *const library = service->get_asset_library_on_disk_custom("My custom lib",
|
||||
asset_library_root_);
|
||||
AssetRepresentation &asset = add_dummy_asset(*library, "path/to/an/asset");
|
||||
|
||||
AssetWeakReference weak_ref = asset.make_weak_reference();
|
||||
AssetWeakReference other;
|
||||
other.asset_library_type = ASSET_LIBRARY_CUSTOM;
|
||||
other.asset_library_identifier = "My custom lib";
|
||||
other.relative_asset_identifier = "path\\to\\an\\asset";
|
||||
EXPECT_EQ(weak_ref, other);
|
||||
|
||||
other.relative_asset_identifier = "";
|
||||
EXPECT_NE(weak_ref, other);
|
||||
other.relative_asset_identifier = nullptr;
|
||||
EXPECT_NE(weak_ref, other);
|
||||
|
||||
/* Make the destructor work. */
|
||||
other.asset_library_identifier = nullptr;
|
||||
other.relative_asset_identifier = nullptr;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "AS_asset_identifier.hh"
|
||||
@@ -78,10 +79,15 @@ bool operator==(const AssetWeakReference &a, const AssetWeakReference &b)
|
||||
if (a.asset_library_type != b.asset_library_type) {
|
||||
return false;
|
||||
}
|
||||
if (StringRef(a.asset_library_identifier) != StringRef(b.asset_library_identifier)) {
|
||||
|
||||
const char *a_lib_idenfifier = a.asset_library_identifier ? a.asset_library_identifier : "";
|
||||
const char *b_lib_idenfifier = b.asset_library_identifier ? b.asset_library_identifier : "";
|
||||
if (BLI_path_cmp_normalized(a_lib_idenfifier, b_lib_idenfifier) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (StringRef(a.relative_asset_identifier) != StringRef(b.relative_asset_identifier)) {
|
||||
const char *a_asset_idenfifier = a.relative_asset_identifier ? a.relative_asset_identifier : "";
|
||||
const char *b_asset_idenfifier = b.relative_asset_identifier ? b.relative_asset_identifier : "";
|
||||
if (BLI_path_cmp_normalized(a_asset_idenfifier, b_asset_idenfifier) != 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user