grame-cncm / guidolib

Guido project - music score layout engine - music description language
http://guido.grame.fr
Mozilla Public License 2.0
152 stars 34 forks source link

guidogetpagemap or guidogetpagecount (core dumped) #148

Open motniemtin opened 2 years ago

motniemtin commented 2 years ago
guidogetpagemap ./test.gmn
# get page mapping for ./test.gmn
Segmentation fault (core dumped)

I meet this error, can not run guidogetpagemap or guidogetpagecount

dfober commented 2 years ago

Please, post the corresponding guido code.

motniemtin commented 2 years ago
(*
  gmn code converted from 
  using libmusicxml v.3.21
  and the embedded xml2guido converter v.3.2
*)
{[ \staff<1> \set<autoHideTiedAccidentals="on"> \barFormat<style= "system", range="1"> 
   (* meas. 1 *)  \clef<"g2"> \key<0> \meter<"3/4", autoBarlines="off", autoMeasuresNum="system"> \stemsDown \beamsOff e2/4 \text<"rit.",fattrib="i", dy=19hs>( \stemsDown \beamBegin:1 d2/8)
 \stemsDown c2/8 \beamEnd:1 \stemsUp \beamBegin:1 a1/8 \stemsUp b1/8 \beamEnd:1 \bar<measNum=2> 
   (* meas. 2 *)  \tempo<"[1/4] = 60", dy=4hs> \stemsDown \beamsOff c2/4 \stemsDown \beamsOff \tieBegin:1 f2/4 \stemsDown \beamBegin:1 f2/16 \tieEnd:1 \stemsDown e2/16 \stemsDown d2/16 \stemsDown c2/16 \beamEnd:1 ]
  }
dfober commented 2 years ago

Can't reproduce the problem. Could you send more information: guido engine version, your platform, etc.

motniemtin commented 2 years ago

I do command guidogetpagecount $guidofile but get Segmentation fault (core dumped)

version 1.7.4 centos 8

dfober commented 2 years ago

Sorry, I don't have any computer running centos. I guess you're using a fresh build of the project and that it has been properly installed. Can you get more information regarding the seg fault? Do you have a similar problem with the other tools ? (e.g. guido2svg)

motniemtin commented 2 years ago

Error happen in guidogetpagecount guidogetpagemap guidogetsystemcount guidogetsystemmap

I found that problem is SVGSystem sys; or CairoSystem sys; Error fix with SVGSystem

dfober commented 2 years ago

GUIDO Graphic device is still based on the old cairo system. It might be due to that. Did you fixed it ?

motniemtin commented 2 years ago

I has fixed for guidogetpagecount.cpp change CairoSystem to SVGSystem


#ifndef WIN32
#include <libgen.h>
#endif
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdlib.h>

#ifdef WIN32
#include "GSystemWin32.h"
GSystemWin32 gSys(0,0);
#elif __APPLE__
#include "GSystemOSX.h"
GSystemOSX gSys (0,0);
#else
#include "CairoSystem.h"
CairoSystem gSys(0);
#endif

#include "GUIDOParse.h"
#include "GUIDOEngine.h"
#include "VGDevice.h"
#include "SVGSystem.h"

using namespace std;

#define kSize   5000

static void error (GuidoErrCode err)
{
    cerr << "error #" << err << ": " << GuidoGetErrorString (err) << endl;
    exit (err);
}

int main(int argc, char **argv)
{
    SVGSystem sys;
    VGDevice *dev = sys.CreateDisplayDevice();
    GuidoInitDesc gd = { dev, 0, 0, 0 };
    GuidoInit (&gd);

    for (int i = 1; i < argc; i++)
    {
        const char* file = argv[i];

        GuidoErrCode err;

        GuidoParser *parser = GuidoOpenParser();
        ARHandler arh = GuidoFile2AR (parser, file);

        if (arh)
        {
            GRHandler grh;
            err = GuidoAR2GR (arh, 0, &grh);
            if (err != guidoNoErr)
                error(err);
            else
            {
                int n = GuidoGetPageCount (grh);
                cout << argv[i] << " : " << n << endl;
                GuidoFreeGR (grh);
            }
            GuidoFreeAR (arh);
        }
        else {
            int line, col;
            err = GuidoParserGetErrorCode (parser, line, col, 0);
            error (err);
        }

        GuidoCloseParser(parser);
    }

    delete dev;

    return 0;
}