I need to close and re-open as the boot runs some checks and such on boot but I suppose I could run the setup on show, I will run some tests thanks for the tip. The QObject.deleteLater() worked like an absolute charm thanks for the heads up!
On 9 December 2015 at 21:08, Justin Israel <[email protected]> wrote: > > > On Thu, Dec 10, 2015 at 9:02 AM Marcus Ottosson <[email protected]> > wrote: > >> Alternative to what Justin and Fredrik said, also consider whether you >> *need* to delete your window. Odds are you can simply hide/show it, which >> would save you some hassle and potentially improve startup time on multiple >> runs. >> > > That is a very valid point. If it isn't expensive to keep around, might as > well just keep it and show it again. > > >> >> On 9 December 2015 at 19:44, Fredrik Averpil <[email protected]> >> wrote: >> >>> I second using QObject.deleteLater() and was just about to recommend >>> that as you can see the "CLOSED" print message. >>> >>> Cheers, >>> Fredrik >>> >>> >>> On Wed, Dec 9, 2015 at 7:35 PM Justin Israel <[email protected]> >>> wrote: >>> >>>> Don't use the del keyword to clean up your windows. That just deletes >>>> python objects and can't guarantee it will delete qt objects. Use >>>> QObject.deleteLater() >>>> >>>> If you make sure "self.mainDialog" is parented to "self" then you only >>>> need to call "self.deleteLater()". Qt will make sure any children of a >>>> deleted object are also deleted. >>>> >>>> You can also achieve this result without needing a custom closeEvent, >>>> if you set a widget attribute: >>>> >>>> self.setAttribute(QtCore.Qt.WA_DeleteOnClose) >>>> >>>> This could either be done in your constructor, or outside the class by >>>> a caller than wants the object it is creating to be deleted when it is >>>> closed. >>>> >>>> On Thu, 10 Dec 2015 7:17 AM Marcus Ottosson <[email protected]> >>>> wrote: >>>> >>>>> If you provide something (minimal) that we could run, it would be much >>>>> easier to help you track down the issue. >>>>> >>>>> On 9 December 2015 at 18:45, Ben Hearn <[email protected]> >>>>> wrote: >>>>> >>>>>> Hey Fredrik, >>>>>> >>>>>> Yes I see the CLOSED print statement when I close the dialog >>>>>> >>>>>> - Ben >>>>>> >>>>>> >>>>>> On Wednesday, 9 December 2015, Fredrik Averpil < >>>>>> [email protected]> wrote: >>>>>> >>>>>>> When you get that error, do you see the "CLOSED" print message at >>>>>>> all? >>>>>>> >>>>>>> >>>>>>> Regards, >>>>>>> Fredrik >>>>>>> >>>>>>> ons 9 dec 2015 kl. 16:48 skrev Benjam901 <[email protected]>: >>>>>>> >>>>>>>> Hello all, >>>>>>>> >>>>>>>> Last week I finally figured out how to successfully stop multiple >>>>>>>> Qt window classed from being open inside Maya. >>>>>>>> >>>>>>>> I checked the window existed and if it did I ignore and pass on the >>>>>>>> condition. >>>>>>>> >>>>>>>> I overrode the close event for my class and when the window was >>>>>>>> closed the class was deleted. This allowed the window to be re-opened >>>>>>>> which >>>>>>>> was exactly what I was after...however. >>>>>>>> >>>>>>>> When an error occurs in the script and I close the window to >>>>>>>> re-boot it, regardless of the close event override the script says the >>>>>>>> window still exists. >>>>>>>> >>>>>>>> Is this the window being stuck in memory because of the error in >>>>>>>> the script? >>>>>>>> >>>>>>>> The below code seems to work brilliantly except for when an error >>>>>>>> occurs. When this happens I close the window and try to re-open it but >>>>>>>> the >>>>>>>> "already exists" condition pops up and I have to re-start Maya >>>>>>>> >>>>>>>> Code is below: >>>>>>>> >>>>>>>> def main(): >>>>>>>> winName = 'EXPORTER' >>>>>>>> if pm.windows.window(winName, exists=True): >>>>>>>> print 'Already exists, passing' >>>>>>>> pass >>>>>>>> else: >>>>>>>> window = ColladaExporterUI() >>>>>>>> window.setObjectName(winName) >>>>>>>> window.show() >>>>>>>> >>>>>>>> >>>>>>>> def closeEvent(self, event): >>>>>>>> print 'CLOSED' >>>>>>>> del self.mainDialog >>>>>>>> del self >>>>>>>> event.accept() >>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "Python Programming for Autodesk Maya" group. >>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>> send an email to [email protected]. >>>>>>>> To view this discussion on the web visit >>>>>>>> https://groups.google.com/d/msgid/python_inside_maya/dcd4ecdf-ac70-411c-8ef9-d32337b96e89%40googlegroups.com >>>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/dcd4ecdf-ac70-411c-8ef9-d32337b96e89%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>>> . >>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to a topic in >>>>>>> the Google Groups "Python Programming for Autodesk Maya" group. >>>>>>> To unsubscribe from this topic, visit >>>>>>> https://groups.google.com/d/topic/python_inside_maya/ilAU64vmbfw/unsubscribe >>>>>>> . >>>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>>> [email protected]. >>>>>>> To view this discussion on the web visit >>>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWPbnGYCx4GjfZ9j1E-tdsTCsMHhCXXac2RNgDUGosshPg%40mail.gmail.com >>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWPbnGYCx4GjfZ9j1E-tdsTCsMHhCXXac2RNgDUGosshPg%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>>> . >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> >>>>>> Tel - +46 76245 92 90 (Sweden) >>>>>> LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Python Programming for Autodesk Maya" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to [email protected]. >>>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkX%3DyGhW5S6xOX59LNAd3Y6rJs99_nVz8tSXmqiEzeTFPQ%40mail.gmail.com >>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkX%3DyGhW5S6xOX59LNAd3Y6rJs99_nVz8tSXmqiEzeTFPQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> *Marcus Ottosson* >>>>> [email protected] >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Python Programming for Autodesk Maya" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODRJbZ03EqYreEFFhfnAuOdwo%3DOqGAdc2Qb-taZCHBO0g%40mail.gmail.com >>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODRJbZ03EqYreEFFhfnAuOdwo%3DOqGAdc2Qb-taZCHBO0g%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Python Programming for Autodesk Maya" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA12%3D%2Bq-vh11vxzGc-szZuqAQ0n5_qazUKeDNvwLiD4LCg%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA12%3D%2Bq-vh11vxzGc-szZuqAQ0n5_qazUKeDNvwLiD4LCg%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Python Programming for Autodesk Maya" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWNunaQG6a-q8Zedjz%3DfskmpgKe51TptMDb4gOYDKW4HSA%40mail.gmail.com >>> <https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWNunaQG6a-q8Zedjz%3DfskmpgKe51TptMDb4gOYDKW4HSA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> *Marcus Ottosson* >> [email protected] >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBdXv6mj3_UQU-d_K3_2-TOtueAhvxCxawCDoZYS0zfQA%40mail.gmail.com >> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBdXv6mj3_UQU-d_K3_2-TOtueAhvxCxawCDoZYS0zfQA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Python Programming for Autodesk Maya" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/python_inside_maya/ilAU64vmbfw/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Per1cMfTeyt_1MPFXTPH%2BhPr8czPTXoLgE2QGsP6UuQ%40mail.gmail.com > <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Per1cMfTeyt_1MPFXTPH%2BhPr8czPTXoLgE2QGsP6UuQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Tel - +46 76245 92 90 (Sweden) LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkUogQJx8NiBa_fZZdWGZugXfDesRHpjHwCL_oy3Txbrgg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
