krassowski / Anki-Night-Mode

Enabling studying at night with Anki - without eye strain
https://ankiweb.net/shared/info/1496166067
GNU General Public License v3.0
72 stars 13 forks source link

Compatibility issue with Arthur-Milchior/anki-fast-note-type-editor #60

Open Arthur-Milchior opened 5 years ago

Arthur-Milchior commented 5 years ago

Problem description

Hi,

I'm the developper of the above-mentionned add-on. I received a bug report https://github.com/Arthur-Milchior/anki-fast-note-type-editor/issues/1 and the user realized it's a compatibility problem between your add-on and mine. I understand that the trouble is that, when night mode is turned on, aqt.clayout.CardLayout.init is redefined. We both redefine it, and of course, it starts to create trouble. However, I must admit I don't understand your code and would love to have an explanation about how it works. Then, I may hopefully either do a pull request to you, or change my code. My trouble is that I don't understand how aqt.clayout.CardLayout.init is changed. It seems that CardLayout is only used in CardLayoutStyler, which itself is never used anyone in your code.

Information about your Anki Setup

Version 2.1.7 (a6c34fd7) Qt 5.12.0 PyQt 5.11.3

Night Mode 2.2.3 OS: Ubuntu

If you have a compatibility problem with a specific add-on or add-ons, please paste the add-on page links below:

Backtrace (if any)

```python" Caught exception: File "C:\Users\John Smith\AppData\Roaming\Anki2\addons21\802285486\clayout.py", line 107, in reject self.mm.save(self.model, templates=True, oldModel = self.originalModel, newTemplatesData = self.newTemplatesData) : 'CardLayout' object has no attribute 'originalModel'```
krassowski commented 5 years ago

Hi @Arthur-Milchior, thanks for letting me know! Just quickly:

https://github.com/krassowski/Anki-Night-Mode/blob/a127d60493dae9bad55830421cf7735d13e6f701/night_mode/stylers.py#L697-L723

Please, let me know if it helps - I am happy to assist you with finding a solution (though this month is though, expect delayed responses).

PS. I've just moved contents in your post around as originally the main text was collapsed in the "Details" section and therefore invisible.

Arthur-Milchior commented 5 years ago

There is a simple and dirty way to force the sorting. I can force my add-on to change the number of its folder, since the loading order is simply decided by the id of the add-on. But I prefer to avoid doing this, it may quickly become far too complicated for what it's worth.

The other solution would be to modify each class calling CardLayout(). Which means that the add-on may become incompatible in yet other way with other add-on, so I don't believe it's such a good idea. Thus, I guess I'll just let the add-on be incompatible and write a message on the Readme page.

I've never heard of metaclass. I've not yet read the whole python documentation. Thanks for letting me know it exists.

krassowski commented 5 years ago

Thus, I guess I'll just let the add-on be incompatible and write a message on the Readme page.

Just out of curiosity, did disabling Card Layout in View → Night Mode → Choose what to style help?