Commits

Aleš Erjavec committed 7ea3b3f

Replaced 'OWReport.report' references with 'OWReport.get_instance()'.

This returns 'qApp.canvasDlg.reportWindow' if present (see #1226).

Comments (0)

Files changed (2)

Orange/OrangeWidgets/OWReport.py

 import xml.dom.minidom
 
 report = None
+
+
+def get_instance():
+    """Return the global ReportWindow instance or None if it was not yet
+    initialized.
+
+    """
+    if hasattr(qApp, "canvasDlg") and hasattr(qApp.canvasDlg, "reportWindow"):
+        return qApp.canvasDlg.reportWindow
+    else:
+        return report
+
+
 def escape(s):
     return s.replace("\\", "\\\\").replace("\n", "\\n").replace("'", "\\'")
 

Orange/OrangeWidgets/OWWidget.py

         
 
         self.__reportData = None
-        if OWReport.report and not noReport and hasattr(self, "sendReport"):
+        if OWReport.get_instance() and not noReport and hasattr(self, "sendReport"):
             self.buttonBackground.show()
             self.reportButton = OWGUI.button(self.buttonBackground, self, "&Report", self.reportAndFinish, debuggingEnabled=0)
             self.reportButton.setAutoDefault(0)
         self.reportName = name or self.windowTitle()
         self.__reportData = ""
         if needDirectory:
-            return OWReport.report.createDirectory()
+            return OWReport.get_instance().createDirectory()
         else:
             return True
 
         self.finishReportList()
 
     def getUniqueFileName(self, patt):
-        return OWReport.report.getUniqueFileName(patt)
+        return OWReport.get_instance().getUniqueFileName(patt)
 
     def getUniqueImageName(self, nm="img", ext=".png"):
-        return OWReport.report.getUniqueFileName(nm + "%06i" + ext)
+        return OWReport.get_instance().getUniqueFileName(nm + "%06i" + ext)
 
     def reportImage(self, filenameOrFunc, *args):
         if self.__reportData is None:
        
     def finishReport(self):
         if self.__reportData is not None:
-            OWReport.report(self.reportName, self.__reportData or "", self.widgetId, self.windowIcon())#, self.getSettings(False))
+            OWReport.get_instance()(self.reportName, self.__reportData or "", self.widgetId, self.windowIcon())#, self.getSettings(False))
             self.__reportData = None
 
 import OWReport