Extension tests, add custom formats with saving and loading (#4950)#5174
Conversation
a478c09 to
6f4300c
Compare
6f4300c to
a4f69bd
Compare
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
a4f69bd to
7d99ade
Compare
|
Had another go at this and implementing the suggestions, it's a bit cleaner now, still have some TODOs to look over though but I wanted to get feedback on the save protection stuff and the general idea. One thing that's nagging at me right now as well is that as it stands now, the script itself is in charge of creating the Sprite itself, and that seems like something we might want to avoid. Originally I left it like that because with adding isModified and having the script have to set the filename, we could leave it open for scripts to open multiple sprites from a single file, but if that's not behavior we intend to support, then I think creating the sprite behind the scenes and then passing it through an argument to the script so it can manipulate the pixels and then we can mark it as saved/etc is gonna be the way to go. Trying to think if there's any use cases that this way of doing things might make impossible though. |
7d99ade to
67f383f
Compare
|
Perhaps the new |
67f383f to
75576c2
Compare
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
75576c2 to
12106e3
Compare
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
12106e3 to
4f7a7c7
Compare
|
There is an assert failing when running |
|
About the API, I think we should be able to specify an |
So there'd be both an I do agree that you could allow |
38b7708 to
5727b66
Compare
|
Fixed the test issues, although I couldn't reproduce the assert issue you were having @dacap, does this happen in a fresh profile? There could be an installed extension causing, maybe this check causes problems? I've made I also added the possibility to use a string or table in the Lastly, I removed the starting "." in some of the error messages regarding formats, so that they can be descriptive instead of just extension based, since this could potentially cause confusion (even with the aseprite format, if you were saving as |
|
Moved the arguments for As for |
1cb2e6c to
eedc484
Compare
|
@dacap Fixed the sorting issue (did not realize we were using the FileFormatsManager order), and fixed the assert, the signals were not getting connected because AppMenus is initialized after extensions so we didn't have the instance available, changed that to a lambda instead of direct connection. |
dacap
left a comment
There was a problem hiding this comment.
Sorry that I'm reviewing this in chunks, but I wasn't able to review all tests yet, it will take some time.
eedc484 to
274635e
Compare
dacap
left a comment
There was a problem hiding this comment.
I wasn't able to check all tests yet, but I've found several fixes that are required in onLoad/onSave mainly (and probably more tests are needed for coverage).
The main thing is that the Lua stack is not kept intact after a onLoad/onSave() on every path (happy path and exception paths). You can check with a helper like this:
struct CheckLStack {
lua_State* L;
int top;
CheckLStack(lua_State* L) : L(L), top(lua_gettop(L)) {}
~CheckLStack() {
PRINTARGS("top", top, "lua_gettop", lua_gettop(L));
ASSERT(top == lua_gettop(L));
}
};
bool onLoad(FileOp* fop) override
{
script::Engine* engine = App::instance()->scriptEngine();
lua_State* L = engine->luaState();
CheckLStack check(L);
...274635e to
d91c65b
Compare
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
|
Fixed all the the stack issues (I just kinda forgot about that huh, maybe we could add a debug-only macro with this stack-checking helper and sprinkle it all over the place so that I don't make that mistake again 🙈). I've added some more tests for the format registration function and for general completeness and especially failure paths. |
Yeah, I was thinking the same (in the past I tried but avoid it because it's too much work for functions that return values). I'll add something after merging this PR. |
|
Looks great! 🥂 |


Implements #4950.
Test extension:
ppm-format.zip