What i changed in my code accidently that this error started?

iEmby wrote on 5/6/2024, 8:45 PM

as i share my new tool for quick rendering in VEGAS for main streams and Social Media Stremes

https://vegasprofreetools.blogspot.com/p/scripts.html

QUICK RENDER

as i share this build link. it is working good but after i may be made some mistake or i don know but main tool is not working on unsaved projects.
as i created some code for that like if user run this tool on unsaved project (new project) it will ask to save or not. if u select save it will show you save as dialog if u select no it will create a temporary project in a folder named temporary project at desktop for emergency need.

but it is working now only on saved genuine saved project.

like this.

this is my starting of code

using ScriptPortal.Vegas;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace Quick_Render_by_iEmby
{
    public partial class QRend : Form
    {
        public Vegas vegas;
        private string projectPath;
        private string renderDirectory;
        bool OverwriteExistingFiles = false;
        private Dictionary<Track, TrackState> trackStates = new Dictionary<Track, TrackState>();

        public QRend(Vegas vegas)
        {
            InitializeComponent();
            this.vegas = vegas;

            if (!IsProjectSaved())
            {
                MessageBox.Show("Please save the project before using this script.");
                this.Close(); 
                return;
            }

            FillTemplates(otherTemplatesCombo);
            selectionBox.Checked = true;

            selectionBox.CheckedChanged += CheckBox_CheckedChanged;
            regionsBox.CheckedChanged += CheckBox_CheckedChanged;
            videotracksBox.CheckedChanged += CheckBox_CheckedChanged;
            audiotracksBox.CheckedChanged += CheckBox_CheckedChanged;
            withoutAudioBox.CheckedChanged += CheckBox_CheckedChanged;

            bool projectContainsAudio = false;
            foreach (Track track in vegas.Project.Tracks)
            {
                if (track.IsAudio())
                {
                    foreach (TrackEvent trackEvent in track.Events)
                    { if (trackEvent.IsAudio()) { projectContainsAudio = true; break; } }
                }

                if (projectContainsAudio)
                { break; }
            }
            if (!projectContainsAudio)
            {
                withoutAudioBox.Enabled = false;
            }
            else
            {
                withoutAudioBox.Enabled = true;
            }
            if (vegas.Project.Regions.Count > 0)
            {
                regionsBox.Enabled = true;
            }
            else
            {
                regionsBox.Enabled = false;
            }

            projectPath = Path.GetDirectoryName(vegas.Project.FilePath);
            renderDirectory = Path.Combine(projectPath, "Renders");
            if (!Directory.Exists(renderDirectory))
            {
                Directory.CreateDirectory(renderDirectory);
            }
        }

        private bool IsProjectSaved()
        {
            if (string.IsNullOrEmpty(vegas.Project.FilePath))
            {
                return false;
            }
            else
            {
                return true;
            }
        }

and this is the ending of my script

public class EntryPoint
{
    private static Quick_Render_by_iEmby.QRend form;

    public void FromVegas(Vegas vegas)
    {
        form = new Quick_Render_by_iEmby.QRend(vegas);
        form.ShowDialog();
    }
}

I don't think other parts may be the problem.

as i asked ChatGPT. it says u r trying to run something which is already disposed off.

Even i tried to add this code still same crashes and errors
 

public QRend(Vegas vegas)
{
    InitializeComponent();
    this.vegas = vegas;

    // Check if the project is untitled and unsaved
    if (vegas.Project == null || string.IsNullOrEmpty(vegas.Project.FilePath))
    {
        // Display a message box indicating that the project is unsaved
        DialogResult dialogResult = MessageBox.Show(
            "PLEASE SAVE YOUR PROJECT FIRST !!\n\nDo you want to save it now?",
            "ATTENTION",
            MessageBoxButtons.YesNo,
            MessageBoxIcon.Warning
        );
        if (dialogResult == DialogResult.Yes)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Vegas Project Files (*.veg)|*.veg";
            saveFileDialog.Title = "Save As Project";

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                vegas.SaveProject(saveFileDialog.FileName);
            }
            else
            {
                return;
            }
        }
        else
        {
            // Define the folder and base file name
            string outputFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Rendering Projects");
            string outputFileName = "Not_Saved_Project_Render";

            // Create the folder if it doesn't exist
            Directory.CreateDirectory(outputFilePath);

            // Find an available file name by appending a counter
            string filePath = Path.Combine(outputFilePath, outputFileName + ".veg");
            int counter = 1;
            while (File.Exists(filePath))
            {
                filePath = Path.Combine(outputFilePath, outputFileName + "_" + counter + ".veg"); // Add parentheses around the counter
                counter++;
            }

            // Save a copy of the project with the specified name
            vegas.Project.SaveProject(filePath);
        }
    }

    FillTemplates(otherTemplatesCombo);
    selectionBox.Checked = true;

    selectionBox.CheckedChanged += CheckBox_CheckedChanged;
    regionsBox.CheckedChanged += CheckBox_CheckedChanged;
    videotracksBox.CheckedChanged += CheckBox_CheckedChanged;
    audiotracksBox.CheckedChanged += CheckBox_CheckedChanged;
    withoutAudioBox.CheckedChanged += CheckBox_CheckedChanged;

    bool projectContainsAudio = false;
    foreach (Track track in vegas.Project.Tracks)
    {
        if (track.IsAudio())
        {
            foreach (TrackEvent trackEvent in track.Events)
            { if (trackEvent.IsAudio()) { projectContainsAudio = true; break; } }
        }

        if (projectContainsAudio)
        { break; }
    }
    if (!projectContainsAudio)
    {
        withoutAudioBox.Enabled = false;
    }
    else
    {
        withoutAudioBox.Enabled = true;
    }
    if (vegas.Project.Regions.Count > 0)
    {
        regionsBox.Enabled = true;
    }
    else
    {
        regionsBox.Enabled = false;
    }

    projectPath = Path.GetDirectoryName(vegas.Project.FilePath);
    renderDirectory = Path.Combine(projectPath, "Renders");
    if (!Directory.Exists(renderDirectory))
    {
        Directory.CreateDirectory(renderDirectory);
    }
}

Don't know where i am wrong. NEED HELP

Last changed by iEmby

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

Comments

No comments yet - be the first to write a comment...