Fix #104857: crash when datafiles/assets folder does not exist
This adds some simple null checks to avoid the crash. It might still be good to improve the error message, but also does not seem as important as avoiding the crash. Typically, users should not run into this issue because the assets are shipped with Blender.
This commit is contained in:
@@ -16,6 +16,9 @@ StringRefNull essentials_directory_path()
|
||||
{
|
||||
static std::string path = []() {
|
||||
const char *datafiles_path = BKE_appdir_folder_id(BLENDER_DATAFILES, "assets");
|
||||
if (datafiles_path == nullptr) {
|
||||
return "";
|
||||
}
|
||||
return datafiles_path;
|
||||
}();
|
||||
return path;
|
||||
|
||||
@@ -63,6 +63,9 @@ AssetLibrary *AssetLibraryService::get_asset_library(
|
||||
switch (type) {
|
||||
case ASSET_LIBRARY_ESSENTIALS: {
|
||||
const StringRefNull root_path = essentials_directory_path();
|
||||
if (root_path.is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AssetLibrary *library = get_asset_library_on_disk(root_path);
|
||||
library->import_method_ = ASSET_IMPORT_APPEND_REUSE;
|
||||
|
||||
Reference in New Issue
Block a user