crocovert / networks

GNU General Public License v3.0
19 stars 3 forks source link

Plugin Networks gives error #12

Closed natanb closed 4 years ago

natanb commented 4 years ago

Hi to all! When change SR in "settings options chane SR" apply we obtain that python error:

RuntimeError: wrapped C/C++ object of type ReseauTi has been deleted Traceback (most recent call last): File "C:/Users/bruno/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\networks\networks_provider.py", line 139, in loadAlgorithms self.addAlgorithm( alg ) RuntimeError: wrapped C/C++ object of type ReseauTi has been deleted

Versione Python: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] Versione di QGIS: 3.4.13-Madeira Madeira, 64ad560

Percorso Python: C:/Users/bruno/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\networks C:/PROGRA1/QGIS 3.4/apps/qgis-ltr/./python C:/Users/bruno/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/Users/bruno/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins C:/PROGRA1/QGIS 3.4/apps/qgis-ltr/./python/plugins C:\Program Files\QGIS 3.4\bin\python37.zip C:\PROGRA1\QGIS 3.4\apps\Python37\DLLs C:\PROGRA1\QGIS 3.4\apps\Python37\lib C:\Program Files\QGIS 3.4\bin C:\PROGRA1\QGIS 3.4\apps\Python37 C:\PROGRA1\QGIS 3.4\apps\Python37\lib\site-packages C:\PROGRA1\QGIS 3.4\apps\Python37\lib\site-packages\win32 C:\PROGRA1\QGIS 3.4\apps\Python37\lib\site-packages\win32\lib C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\Pythonwin C:/Users/bruno/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/Users/bruno/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\timeseriesviewerplugin C:\Users\bruno\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\timeseriesviewerplugin\eotimeseriesviewer

After that the Networks app disappears! If you repeat the Climb app disappers!?

I "google" but seems tied to create/destroy objects in python code!? I'm not a "pythonist" then ask to expert to find the bug.

natanb commented 4 years ago

As suggest by Gustry: https://github.com/qgis/QGIS/issues/33352

I change the code networks_provider.py (and Climb plugin, it gives same error!)

-- coding: utf-8 --

""" /*** Networks A QGIS plugin Networks Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/

    begin                : 2018-02-26
    copyright            : (C) 2018 by Patrick Palmier
    email                : patrick.palmier@cerema.fr

***/

/***

author = 'Patrick Palmier' date = '2018-02-26' copyright = '(C) 2018 by Patrick Palmier'

This will get replaced with a git SHA1 when you do a git archive

revision = '$Format:%H$' from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication from qgis.PyQt.QtWidgets import QApplication,QMenu,QAction from qgis.core import QgsProcessingProvider,QgsApplication from processing.core.Processing import Processing from processing.core.ProcessingConfig import ProcessingConfig, Setting from .reseau_ti import ReseauTi from .ajout_champ import AjoutChamp from .concat_reseaux import ConcatReseaux from .connecteurs_geo import ConnecteursGeo from .contours import Contours from .creer_graphe import CreerGraphe from .interpole import Interpole from .maj_titj import Majtitj from .import_gtfs import ImportGTFS from .inverser import Inverser from .inverser_selection import InverserSelection from .reseau_tc import ReseauTC from .prepare_gtfs import PrepareGTFS from .connect_nodes2lines import ConnectNodes2Lines from .calcul_musliw import CalculMusliw from .param_musliw import MusliwParam from .simple_matrix import SimpleMatrix from .matrix_simple_liste import MatrixSimpleList from .matrix_double_liste import MatrixDoubleList from .noeuds_isoles import IsolatedNodes from .fichier_aff import FichierAff from .decaler_lignes import ShiftLines from .fichier_od import FichierOD from .fichier_temps import FichierTemps from .trafic import Trafic from .spatial_aggregation import SpatialAggregation from .routes import Routes from .path_analysis import PathAnalysis from .create_ti_arcs import ArcsTi from .maj_links_times import MajLinksTimes from .fichier_noeuds import NodesFile from .autoconnectors import AutoConnecteurs

from qgis.PyQt.QtGui import QIcon import os

pluginPath = os.path.dirname(file)

class NetworksProvider(QgsProcessingProvider):

def __init__(self):
    QgsProcessingProvider.__init__(self)
    """
    # Load algorithms
    self.alglist = [ReseauTi(),
                    AjoutChamp(),
                    ConcatReseaux(),
                    ConnecteursGeo(),
                    Contours(),
                    CreerGraphe(),
                    Interpole(),
                    Majtitj(),
                    ImportGTFS(),
                    Inverser(),
                    InverserSelection(),
                    ReseauTC(),
                    PrepareGTFS(),
                    ConnectNodes2Lines(),
                    CalculMusliw(),
                    MusliwParam(),
                    SimpleMatrix(),
                    MatrixSimpleList(),
                    MatrixDoubleList(),
                    IsolatedNodes(),
                    FichierAff(),
                    ShiftLines(),
                    FichierOD(),
                    FichierTemps(),
                    Trafic(),
                    SpatialAggregation(),
                    Routes(),
                    PathAnalysis(),
                    ArcsTi(),
                    MajLinksTimes(),
                    NodesFile(),
                    AutoConnecteurs()]
    """
    self.plugin_dir = os.path.dirname(__file__)
    # initialize locale
    locale = QSettings().value('locale/userLocale')[0:2]
    locale_path = os.path.join(
        self.plugin_dir,
        'i18n',
        'networks_{0}.qm'.format(locale))

    if os.path.exists(locale_path):
        self.translator = QTranslator()
        self.translator.load(locale_path)
        QCoreApplication.installTranslator(self.translator)

def unload(self):
    """
    Unloads the provider. Any tear-down steps required by the provider
    should be implemented here.
    """
    pass

def loadAlgorithms(self):

    """
    Loads all algorithms belonging to this provider.

    for alg in self.alglist:
    """
    self.addAlgorithm( ReseauTi() )
    self.addAlgorithm( AjoutChamp() )
    self.addAlgorithm( ConcatReseaux() )
    self.addAlgorithm( ConnecteursGeo() )
    self.addAlgorithm( Contours() )
    self.addAlgorithm(CreerGraphe())
    self.addAlgorithm(Interpole())
    self.addAlgorithm(Majtitj())
    self.addAlgorithm(ImportGTFS())
    self.addAlgorithm(Inverser())
    self.addAlgorithm(InverserSelection())
    self.addAlgorithm(ReseauTC())
    self.addAlgorithm(PrepareGTFS())
    self.addAlgorithm(ConnectNodes2Lines())
    self.addAlgorithm(CalculMusliw())
    self.addAlgorithm(MusliwParam())
    self.addAlgorithm(SimpleMatrix())
    self.addAlgorithm(MatrixSimpleList())
    self.addAlgorithm(MatrixDoubleList())
    self.addAlgorithm(IsolatedNodes())
    self.addAlgorithm(FichierAff())
    self.addAlgorithm(ShiftLines())
    self.addAlgorithm(FichierOD())
    self.addAlgorithm(FichierTemps())
    self.addAlgorithm(Trafic())
    self.addAlgorithm(SpatialAggregation())
    self.addAlgorithm(Routes())
    self.addAlgorithm(PathAnalysis())
    self.addAlgorithm(ArcsTi())
    self.addAlgorithm(MajLinksTimes())
    self.addAlgorithm(NodesFile())
    self.addAlgorithm(AutoConnecteurs())

def id(self):
    """
    Returns the unique provider id, used for identifying the provider. This
    string should be a unique, short, character only string, eg "qgis" or
    "gdal". This string should not be localised.
    """
    return 'Networks'

def icon(self):
    return QIcon(os.path.join(pluginPath, "icons", "cerema.png"))

def name(self):
    """
    Returns the provider name, which is used to describe the provider
    within the GUI.

    This string should be short (e.g. "Lastools") and localised.
    """
    return self.tr('Networks')

def longName(self):
    """
    Returns the a longer version of the provider name, which can include
    extra details such as version numbers. E.g. "Lastools LIDAR tools
    (version 2.2.1)". This string should be localised. The default
    implementation returns the same string as name().
    """
    return self.name()