Skip to content
Snippets Groups Projects

modified run_shifter to be thread safe and fixed the steps when image is shifted

Merged mhby1g21 requested to merge fixing-shifter-checkbox-crash into master
2 files
+ 66
17
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -104,18 +104,38 @@ class ShifterTab(QWidget):
scrollbar.setValue(scrollbar.maximum())
def run_shifter(self):
"""GUI version of shifter - calls the thread-safe version"""
if not self.input_file_path:
QMessageBox.warning(self, "Warning", "Please select an input file first")
return
return False
self.update_status("\nRunning image shifter...")
success, _ = run_command(
self,
self.cmd_text.toPlainText(),
self.update_status
)
success, _ = self.run_shifter_process(self.update_status)
if success and os.path.exists(self.shifted_image_path):
self.update_status(f"Shifted image saved to: {self.shifted_image_path}")
update_preview(self.output_preview, self.shifted_image_path,
error_callback=self.update_status)
\ No newline at end of file
error_callback=self.update_status)
return success
def run_shifter_process(self, status_callback=None):
"""Thread-safe version of shifter that doesn't use GUI components"""
try:
if not self.input_file_path:
raise ValueError("No input file selected")
# Construct command without using GUI components
conda_dir = self.config_reader.config["condaDir"]
material_env = self.config_reader.config["materialEnv"]
shifter_script = os.path.join(self.config_reader.directories['scriptDir'], "shifter.py")
command = f'"{conda_dir}\\condabin\\activate.bat" {material_env} && ' \
f'python "{shifter_script}" "{self.input_file_path}" "{self.shifted_image_path}"'
# Run the command
return run_command(None, command, status_callback)
except Exception as e:
if status_callback:
status_callback(f"Error in shifter process: {str(e)}")
return False, str(e)
\ No newline at end of file
Loading