Skip to content

Conversation

@musabkilic
Copy link
Contributor

@musabkilic musabkilic commented Oct 1, 2020

List of Changes

I changed open_file_if_needed function in manim/main.py to fix #484

Motivation

There is a bug to be fixed.

Explanation for Changes

#484 (comment)

I changed the code so open_media_file runs twice if both -f and -p is given.

Testing Status

Tested on Windows, but future testing is highly recommended.

Further Comments

I'm open to other suggestions on how to fix this problem in other ways, but I hope I explained the core reason why this bug exists.

Acknowledgement

Copy link
Contributor

@leotrs leotrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Now I'm curious how is it that it worked for @naveen521kk ?

@huguesdevimeux huguesdevimeux self-requested a review October 2, 2020 06:27
Copy link
Member

@huguesdevimeux huguesdevimeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to me good but what I don't like is that you are basically writting exactly what open_media_file is supposed to do.
Intstead, I think you should change open_media_file directly, and not touch main.

@musabkilic
Copy link
Contributor Author

The thing is, we need to touch main.

manim/manim/__main__.py

Lines 25 to 43 in 97de346

open_file = any(
[file_writer_config["preview"], file_writer_config["show_in_file_browser"]]
)
if open_file:
current_os = platform.system()
file_paths = []
if file_writer_config["save_last_frame"]:
file_paths.append(file_writer.get_image_file_path())
if (
file_writer_config["write_to_movie"]
and not file_writer_config["save_as_gif"]
):
file_paths.append(file_writer.get_movie_file_path())
if file_writer_config["save_as_gif"]:
file_paths.append(file_writer.gif_file_path)
for file_path in file_paths:
open_media_file(file_path, file_writer_config["show_in_file_browser"])

Let's call file_writer_config["preview"] p and file_writer_config["show_in_file_browser"] f. We know this runs when either of them is true, so we know p ∨ f≡ 1 and we pass f to open_media_file. If f ≡ 0 → p ≡ 1 but if f ≡ 1 there is no way to determine p.

Copy link
Member

@huguesdevimeux huguesdevimeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, Thanks for contributing !

SGTM !

@huguesdevimeux huguesdevimeux merged commit 57158c3 into ManimCommunity:master Oct 2, 2020
@naveen521kk
Copy link
Member

Now I'm curious how is it that it worked for @naveen521kk ?

Previously passing fp just opened explorer but not it opens both video player and explorer.

@leotrs
Copy link
Contributor

leotrs commented Oct 2, 2020

Opening both is what it was always meant to do 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-fp does not work on Ubuntu

4 participants