Skip to content

Commit

Permalink
Fix wrong path being used to detect if an addon is an extension or not
Browse files Browse the repository at this point in the history
  • Loading branch information
strike-digital committed Jul 7, 2024
1 parent a1d8af9 commit 36b513f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pythonFiles/include/blender_vscode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def startup(editor_address, addons_to_load: list[AddonInfo], allow_modify_extern
from . import communication
communication.setup(editor_address, path_mappings)

load_addons.load(addons_to_load)

from . import operators, ui

ui.register()
operators.register()

load_addons.load(addons_to_load)

def handle_fatal_error(message):
print()
print("#"*80)
Expand Down
3 changes: 2 additions & 1 deletion pythonFiles/include/blender_vscode/load_addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def load(addons_to_load: list[AddonInfo]):
addon_name = addon_info.module_path

try:
bpy.ops.preferences.addon_enable(module=addon_name)
# bpy.ops.preferences.addon_enable(module=addon_name)
bpy.ops.dev.update_addon(module_name=addon_name)
except:
traceback.print_exc()
send_dict_as_json({"type": "enableFailure", "addonPath": str(addon_info.load_dir)})
Expand Down
10 changes: 6 additions & 4 deletions src/addon_folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import {

export class AddonWorkspaceFolder {
folder: vscode.WorkspaceFolder;
isLegacy: boolean;

constructor(folder: vscode.WorkspaceFolder) {
this.folder = folder;
this.isLegacy = fs.existsSync(path.join(folder.uri.fsPath, "blender_manifest.toml"));
}

public static async All() {
Expand Down Expand Up @@ -53,6 +51,10 @@ export class AddonWorkspaceFolder {
return <boolean>this.getConfig().get('addon.justMyCode');
}

public async isLegacy() {
return fs.existsSync(path.join(await this.getSourceDirectory(), "blender_manifest.toml"))
}

public async hasAddonEntryPoint() {
try {
let sourceDir = await this.getSourceDirectory();
Expand Down Expand Up @@ -88,7 +90,7 @@ export class AddonWorkspaceFolder {
let value = <string>getConfig(this.uri).get('addon.moduleName');
if (value === 'auto') {
let module_base = path.basename(await this.getLoadDirectory());
if (this.isLegacy) {
if (await this.isLegacy()) {
module_base = "bl_ext.user_default.".concat(module_base)
}
return module_base;
Expand All @@ -100,7 +102,7 @@ export class AddonWorkspaceFolder {

public async getModuleName() {
let path = await this.getModulePath();
if (this.isLegacy) {
if (await this.isLegacy()) {
return path.split(".").slice(-1)[0];
}
return path
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async function reloadAddons(addons: AddonWorkspaceFolder[]) {
await rebuildAddons(addons);
let names = await Promise.all(addons.map(a => a.getModuleName()));
let paths = await Promise.all(addons.map(a => a.getModulePath()))
let dirs = await Promise.all(addons.map(a => a.folder.uri.fsPath))
let dirs = await Promise.all(addons.map(a => a.getSourceDirectory()))
instances.forEach(instance => instance.post({ type: 'reload', names: names, paths: paths, dirs: dirs}));
}

Expand Down

0 comments on commit 36b513f

Please sign in to comment.