mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Fix leaking FileDialog by issuing Destroy to it after it has been used
This also works around the bug in GTK in its file system tracking/file open dialog that causes a crash when a file (in a directory it is tracking, such as the previous directry where an STL was sliced from) is modified with vim. Steps to reproduce the bug: 1) Slice a file from the GUI 2) vim test.stl in the same directory 3) i hello ESC ZZ 4) if Slic3r didn't crash to a gtk assertion failure, jump to step 2 5) if still no luck, your gtk isn't broken. What version do you have?-)
This commit is contained in:
		
							parent
							
								
									29b9c31b92
								
							
						
					
					
						commit
						10d4271c01
					
				
					 1 changed files with 12 additions and 2 deletions
				
			
		| 
						 | 
					@ -189,8 +189,12 @@ sub do_slice {
 | 
				
			||||||
        my $input_file;
 | 
					        my $input_file;
 | 
				
			||||||
        if (!$params{reslice}) {
 | 
					        if (!$params{reslice}) {
 | 
				
			||||||
            my $dialog = Wx::FileDialog->new($self, 'Choose a STL or AMF file to slice:', $dir, "", $model_wildcard, wxFD_OPEN);
 | 
					            my $dialog = Wx::FileDialog->new($self, 'Choose a STL or AMF file to slice:', $dir, "", $model_wildcard, wxFD_OPEN);
 | 
				
			||||||
            return unless $dialog->ShowModal == wxID_OK;
 | 
					            if ($dialog->ShowModal != wxID_OK) {
 | 
				
			||||||
 | 
					                $dialog->Destroy;
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            $input_file = $dialog->GetPaths;
 | 
					            $input_file = $dialog->GetPaths;
 | 
				
			||||||
 | 
					            $dialog->Destroy;
 | 
				
			||||||
            $last_input_file = $input_file;
 | 
					            $last_input_file = $input_file;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            if (!defined $last_input_file) {
 | 
					            if (!defined $last_input_file) {
 | 
				
			||||||
| 
						 | 
					@ -229,9 +233,13 @@ sub do_slice {
 | 
				
			||||||
            $output_file =~ s/\.gcode$/.svg/i if $params{export_svg};
 | 
					            $output_file =~ s/\.gcode$/.svg/i if $params{export_svg};
 | 
				
			||||||
            my $dlg = Wx::FileDialog->new($self, 'Save ' . ($params{export_svg} ? 'SVG' : 'G-code') . ' file as:', dirname($output_file),
 | 
					            my $dlg = Wx::FileDialog->new($self, 'Save ' . ($params{export_svg} ? 'SVG' : 'G-code') . ' file as:', dirname($output_file),
 | 
				
			||||||
                basename($output_file), $gcode_wildcard, wxFD_SAVE);
 | 
					                basename($output_file), $gcode_wildcard, wxFD_SAVE);
 | 
				
			||||||
            return if $dlg->ShowModal != wxID_OK;
 | 
					            if ($dlg->ShowModal != wxID_OK) {
 | 
				
			||||||
 | 
					                $dlg->Destroy;
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            $skein->output_file($dlg->GetPath);
 | 
					            $skein->output_file($dlg->GetPath);
 | 
				
			||||||
            $last_output_file = $dlg->GetPath;
 | 
					            $last_output_file = $dlg->GetPath;
 | 
				
			||||||
 | 
					            $dlg->Destroy;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        # show processbar dialog
 | 
					        # show processbar dialog
 | 
				
			||||||
| 
						 | 
					@ -288,6 +296,7 @@ sub save_config {
 | 
				
			||||||
        $last_config = $file;
 | 
					        $last_config = $file;
 | 
				
			||||||
        Slic3r::Config->save($file);
 | 
					        Slic3r::Config->save($file);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    $dlg->Destroy;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sub load_config {
 | 
					sub load_config {
 | 
				
			||||||
| 
						 | 
					@ -307,6 +316,7 @@ sub load_config {
 | 
				
			||||||
        $self->catch_error();
 | 
					        $self->catch_error();
 | 
				
			||||||
        $_->() for @Slic3r::GUI::OptionsGroup::reload_callbacks;
 | 
					        $_->() for @Slic3r::GUI::OptionsGroup::reload_callbacks;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    $dlg->Destroy;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sub catch_error {
 | 
					sub catch_error {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue