Skip to content

Fixing libopenshot version warning message + Sentry.io fixes #4333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/classes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ def check_libopenshot_version(self, info, openshot):
},
level="error",
))
raise RuntimeError(
Copy link
Member Author

Choose a reason for hiding this comment

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

This was preventing the OpenShotApp from initializing

"libopenshot version {} found, minimum is {}".format(ver, min_ver))

def gui(self):
from classes import language, sentry, ui_util, logger_libopenshot
Expand Down
32 changes: 22 additions & 10 deletions src/classes/json_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ def convert_paths_to_absolute(self, file_path, data):
# Optimized regex replacement
data = re.sub(path_regex, self.replace_string_to_absolute, data)

except Exception as ex:
log.error("Error while converting relative paths to absolute paths: %s" % str(ex))
except Exception:
log.error("Error while converting relative paths to absolute paths", exc_info=1)

return data

Expand All @@ -266,14 +266,16 @@ def replace_string_to_relative(self, match):

# Determine if thumbnail path is found
if info.THUMBNAIL_PATH in folder_path:
# Convert path to relative thumbnail path
log.debug("Generating relative thumbnail path to %s in %s",
file_path, folder_path)
new_path = os.path.join("thumbnail", file_path).replace("\\", "/")
new_path = json.dumps(new_path, ensure_ascii=False)
return '"%s": %s' % (key, new_path)

# Determine if @transitions path is found
elif os.path.join(info.PATH, "transitions") in folder_path:
# Yes, this is an OpenShot transition
log.debug("Generating relative @transitions path for %s in %s",
file_path, folder_path)
folder_path, category_path = os.path.split(folder_path)

# Convert path to @transitions/ path
Expand All @@ -283,15 +285,15 @@ def replace_string_to_relative(self, match):

# Determine if @emojis path is found
elif os.path.join(info.PATH, "emojis") in folder_path:
# Yes, this is an OpenShot emoji
# Convert path to @emojis/ path
log.debug("Generating relative @emojis path for %s in %s",
file_path, folder_path)
new_path = os.path.join("@emojis", file_path).replace("\\", "/")
new_path = json.dumps(new_path, ensure_ascii=False)
return '"%s": %s' % (key, new_path)

# Determine if @assets path is found
elif path_context["new_project_assets"] in folder_path:
# Yes, this is an OpenShot transitions
log.debug("Replacing path to %s in %s", file_path, folder_path)
folder_path = folder_path.replace(path_context["new_project_assets"], "@assets")

# Convert path to @assets/ path
Expand All @@ -304,10 +306,20 @@ def replace_string_to_relative(self, match):
# Convert path to the correct relative path (based on the existing folder)
orig_abs_path = os.path.abspath(path)

# Determine windows drives that the project and file are on
project_win_drive = os.path.splitdrive(path_context.get("new_project_folder", ""))[0]
file_win_drive = os.path.splitdrive(path)[0]
if file_win_drive != project_win_drive:
log.debug("Drive mismatch, not making path relative: %s", orig_abs_path)
# If the file is on different drive. Don't abbreviate the path.
clean_path = orig_abs_path.replace("\\", "/")
clean_path = json.dumps(clean_path, ensure_ascii=False)
return f"{key}: {clean_path}"

# Remove file from abs path
orig_abs_folder = os.path.dirname(orig_abs_path)

# Calculate new relateive path
log.debug("Generating new relative path for %s", orig_abs_path)
new_rel_path_folder = os.path.relpath(orig_abs_folder, path_context.get("new_project_folder", ""))
new_rel_path = os.path.join(new_rel_path_folder, file_path).replace("\\", "/")
new_rel_path = json.dumps(new_rel_path, ensure_ascii=False)
Expand All @@ -328,8 +340,8 @@ def convert_paths_to_relative(self, file_path, previous_path, data):
# Optimized regex replacement
data = re.sub(path_regex, self.replace_string_to_relative, data)

except Exception as ex:
log.error("Error while converting absolute paths to relative paths: %s" % str(ex))
except Exception:
log.error("Error while converting absolute paths to relative paths", exc_info=1)

return data

Expand Down
5 changes: 1 addition & 4 deletions src/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,7 @@ def main():
argv = [sys.argv[0]]
argv.extend(extra_args)
argv.extend(args.remain)
try:
app = OpenShotApp(argv)
except Exception:
app.show_errors()
Copy link
Member Author

@jonoomph jonoomph Aug 22, 2021

Choose a reason for hiding this comment

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

app was never initialized in the except block... and below a few lines, we call app.gui() which displays the errors... if a gui is created.

app = OpenShotApp(argv)

# Setup Qt application details
app.setApplicationName('openshot')
Expand Down
12 changes: 8 additions & 4 deletions src/timeline/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,9 @@ App.controller("TimelineCtrl", function ($scope) {
timeline.add_missing_transition(JSON.stringify(missing_transition_details));
}
// Remove manual move stylesheet
bounding_box.element.removeClass("manual-move");
if (bounding_box.element) {
bounding_box.element.removeClass("manual-move");
}

// Remove CSS class (after the drag)
bounding_box = {};
Expand Down Expand Up @@ -894,7 +896,7 @@ App.controller("TimelineCtrl", function ($scope) {
bounding_box.track_position = 0;

// Set z-order to be above other clips/transitions
if (item_type !== "os_drop") {
if (item_type !== "os_drop" && bounding_box.element) {
bounding_box.element.addClass("manual-move");
}
};
Expand Down Expand Up @@ -938,8 +940,10 @@ App.controller("TimelineCtrl", function ($scope) {
}
}
//change the element location
bounding_box.element.css("left", results.position.left);
bounding_box.element.css("top", bounding_box.track_position - scrolling_tracks_offset_top);
if (bounding_box.element) {
bounding_box.element.css("left", results.position.left);
bounding_box.element.css("top", bounding_box.track_position - scrolling_tracks_offset_top);
}
};

// Update X,Y indexes of tracks / layers (anytime the project.layers scope changes)
Expand Down
7 changes: 5 additions & 2 deletions src/windows/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ def titlestring(sec, fps, mess):
# get translations
_ = get_app()._tr

# Init some variables
seconds_run = 0
fps_encode = 0

# Init progress bar
self.progressExportVideo.setMinimum(self.txtStartFrame.value())
self.progressExportVideo.setMaximum(self.txtEndFrame.value())
Expand Down Expand Up @@ -872,7 +876,6 @@ def titlestring(sec, fps, mess):

progressstep = max(1 , round(( video_settings.get("end_frame") - video_settings.get("start_frame") ) / 1000))
start_time_export = time.time()
seconds_run = 0
start_frame_export = video_settings.get("start_frame")
end_frame_export = video_settings.get("end_frame")
last_exported_time = time.time()
Expand All @@ -881,7 +884,7 @@ def titlestring(sec, fps, mess):
digits_after_decimalpoint = 1
# Precision of the progress bar
format_of_progress_string = "%4.1f%% "
fps_encode = 0

# Write each frame in the selected range
for frame in range(video_settings.get("start_frame"), video_settings.get("end_frame") + 1):
# Update progress bar (emit signal to main window)
Expand Down
20 changes: 10 additions & 10 deletions src/windows/models/properties_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ def remove_keyframe(self, item):
if not c:
return

# Create reference
# Create reference
clip_data = c.data
if object_id:
clip_data = c.data.get('objects').get(object_id)

if property_key in clip_data: # Update clip attribute
log_id = "{}/{}".format(clip_id, object_id) if object_id else clip_id
log.debug("%s: remove %s keyframe. %s", log_id, property_key, clip_data.get(property_key))
Expand Down Expand Up @@ -281,7 +281,7 @@ def color_update(self, item, new_color, interpolation=-1, interpolation_details=
c = Effect.get(id=clip_id)

if c:
# Create reference
# Create reference
clip_data = c.data
if object_id:
clip_data = c.data.get('objects').get(object_id)
Expand All @@ -301,7 +301,7 @@ def color_update(self, item, new_color, interpolation=-1, interpolation_details=
# Keyframe
# Loop through points, find a matching points on this frame
found_point = False
for point in clip_data[property_key][color]["Points"]:
for point in clip_data[property_key][color].get("Points", []):
log.debug("looping points: co.X = %s" % point["co"]["X"])
if interpolation == -1 and point["co"]["X"] == self.frame_number:
# Found point, Update value
Expand Down Expand Up @@ -348,7 +348,7 @@ def color_update(self, item, new_color, interpolation=-1, interpolation_details=
if not found_point:
clip_updated = True
log.debug("Created new point at X=%d", self.frame_number)
clip_data[property_key][color]["Points"].append({
clip_data[property_key][color].setdefault("Points", []).append({
'co': {'X': self.frame_number, 'Y': new_value},
'interpolation': 1,
})
Expand All @@ -357,7 +357,7 @@ def color_update(self, item, new_color, interpolation=-1, interpolation_details=
clip_data = {property_key: clip_data[property_key]}
if object_id:
clip_data = {'objects': {object_id: clip_data}}

# Save changes
if clip_updated:
# Save
Expand Down Expand Up @@ -430,8 +430,8 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
c = Effect.get(id=clip_id)

if c:
# Create reference

# Create reference
clip_data = c.data
if object_id:
clip_data = c.data.get('objects').get(object_id)
Expand All @@ -447,7 +447,7 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
# Loop through points, find a matching points on this frame
found_point = False
point_to_delete = None
for point in clip_data[property_key]["Points"]:
for point in clip_data[property_key].get('Points', []):
log.debug("looping points: co.X = %s" % point["co"]["X"])
if interpolation == -1 and point["co"]["X"] == self.frame_number:
# Found point, Update value
Expand Down Expand Up @@ -503,7 +503,7 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
elif not found_point and new_value is not None:
clip_updated = True
log.debug("Created new point at X=%d", self.frame_number)
clip_data[property_key]["Points"].append({
clip_data[property_key].setdefault('Points', []).append({
'co': {'X': self.frame_number, 'Y': new_value},
'interpolation': 1})

Expand Down
2 changes: 1 addition & 1 deletion src/windows/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def Populate(self, filter=""):
widget.setMinimum(int(param["min"]))
widget.setMaximum(int(param["max"]))
widget.setValue(int(param["value"]))
widget.setSingleStep(1.0)
widget.setSingleStep(1)
widget.setToolTip(param["title"])
widget.valueChanged.connect(functools.partial(self.spinner_value_changed, param))

Expand Down
2 changes: 1 addition & 1 deletion src/windows/process_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(self, clip_id, effect_name, effect_params):
widget.setMinimum(int(param["min"]))
widget.setMaximum(int(param["max"]))
widget.setValue(int(param["value"]))
widget.setSingleStep(1.0)
widget.setSingleStep(1)
widget.setToolTip(_(param["title"]))
widget.valueChanged.connect(functools.partial(self.spinner_value_changed, widget, param))

Expand Down
4 changes: 2 additions & 2 deletions src/windows/views/blender_listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,8 @@ def Render(self):
if self.canceled:
return
if self.frame_count < 1:
log.error("No frame detected from Blender!")
log.error("Blender output:\n{}".format(
log.warning("No frame detected from Blender!")
log.warning("Blender output:\n{}".format(
self.command_output))
# Show Error that no frames are detected. This is likely caused by
# the wrong command being executed... or an error in Blender.
Expand Down
41 changes: 24 additions & 17 deletions src/windows/views/properties_tableview.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,11 @@ def contextMenuEvent(self, event):
# Instantiate the timeline
timeline_instance = get_app().window.timeline_sync.timeline
current_effect = timeline_instance.GetClipEffect(clip_id)

# Loop through timeline's clips
for clip_instance in timeline_instance.Clips():
clip_instance_id = clip_instance.Id()

# Avoid attach a clip to it's own object
if (clip_instance_id != clip_id and (current_effect and clip_instance_id != current_effect.ParentClip().Id())):
# Clip's propertyJSON data
Expand Down Expand Up @@ -674,20 +674,6 @@ def contextMenuEvent(self, event):
fontinfo = QFontInfo(font)
self.clip_properties_model.value_updated(self.selected_item, value=fontinfo.family())

elif self.property_type == "color":
# Get current value of color
red = cur_property[1]["red"]["value"]
green = cur_property[1]["green"]["value"]
blue = cur_property[1]["blue"]["value"]

# Show color dialog
currentColor = QColor(red, green, blue)
log.debug("Launching ColorPicker for %s", currentColor.name())
ColorPicker(
currentColor, parent=self, title=_("Select a Color"),
callback=self.color_callback)
return

# Define bezier presets
bezier_presets = [
(0.250, 0.100, 0.250, 1.000, _("Ease (Default)")),
Expand Down Expand Up @@ -725,6 +711,10 @@ def contextMenuEvent(self, event):

# Add menu options for keyframes
menu = QMenu(self)
if self.property_type == "color":
Color_Action = menu.addAction(_("Select a Color"))
Color_Action.triggered.connect(functools.partial(self.Color_Picker_Triggered, cur_property))
menu.addSeparator()
if points > 1:
# Menu items only for multiple points
Bezier_Menu = menu.addMenu(self.bezier_icon, _("Bezier"))
Expand Down Expand Up @@ -764,7 +754,7 @@ def contextMenuEvent(self, event):
SubMenuRoot = menu.addMenu(choice["icon"], choice["name"])
else:
SubMenuRoot = menu.addMenu(choice["name"])

SubMenuSize = 25
SubMenuNumber = 0
if len(choice["value"]) > SubMenuSize:
Expand Down Expand Up @@ -819,6 +809,23 @@ def Constant_Action_Triggered(self):
# Update colors interpolation mode
self.clip_properties_model.color_update(self.selected_item, QColor("#000"), interpolation=2, interpolation_details=[])

def Color_Picker_Triggered(self, cur_property):
log.info("Color_Picker_Triggered")

_ = get_app()._tr

# Get current value of color
red = cur_property[1]["red"]["value"]
green = cur_property[1]["green"]["value"]
blue = cur_property[1]["blue"]["value"]

# Show color dialog
currentColor = QColor(red, green, blue)
log.debug("Launching ColorPicker for %s", currentColor.name())
ColorPicker(
currentColor, parent=self, title=_("Select a Color"),
callback=self.color_callback)

def Insert_Action_Triggered(self):
log.info("Insert_Action_Triggered")
if self.selected_item:
Expand Down