Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
babakar
Posts: 770
Registered: ‎05-29-2012
My Device: see later

Process 1780056901 (Zain) terminated SIGSEGV code=1 fltno=11 ip=00000000 image upload

void ApplicationUI::getPicture()
{
FilePicker* filePicker = new FilePicker();
filePicker->setType(FileType::Picture);
filePicker->setTitle("Select Picture");
filePicker->setMode(FilePickerMode::Picker);
filePicker->open();
QObject::connect(filePicker,
        SIGNAL(fileSelected(const QStringList&)),
        this,
        SLOT(onFileSelected(const QStringList&)));

  }
      void ApplicationUI::onFileSelected(const QStringList& list) {
try
{
    QFile file (list[0]);
    ImageView* ay = root->findChild<ImageView*>("imageName");
    if(ay != NULL)
        ay->setImage(Image(list[0]));
    QString body = "" ;
    QSettings settings("Netvariant", "Zain");
    QString locale_string = settings.value("lang").toString();
    if(locale_string == "ar")
        locale_string == "ar";
    else
        locale_string = "en";
    const QUrl url("myurl");
     QHttpPart imagePart;
     imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
     imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"imageFile\""));
     imagePart.setRawHeader("Content-ID", "my@content.id"); // add any headers you like via setRawHeader()
     file.open(QIODevice::ReadOnly);
     imagePart.setBodyDevice(&file);
     QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
     file.setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart
      multiPart->append(imagePart);
      QNetworkRequest request(url);

      QNetworkAccessManager* netManager = new QNetworkAccessManager(this);
      QNetworkReply *reply = netManager->post(request, multiPart);


}
catch(...)
{

}
 }

 

please help me in uploading an image.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Process 1780056901 (Zain) terminated SIGSEGV code=1 fltno=11 ip=00000000 image upload

In my experience, the error you see is a result of an incorrect pointer, that you think is pointing at some object or storage you can use and is not. 

 

To track this down is usually pretty straight forward.  You run the code in the debugger, and when it breaks, the debugger stops on the statement that failed.  At that time you have access to the variables, and so you can check what is valid and what is not.

 

In my experience, these problems are always a result of some error in my code, for example, not checking that a pointer is valid, not initialising a pointer or freeing some object or storage that the pointer is referencing.  I strongly suspect you will find something wrong in your code.

 

But from the informaiton we have, we would just be guessing so we can't help you further.  Next time you report an error like this, I recommend you give us as much informaiton as you can, for example, the line that this exception is happening on, and the contents of the variables involved.  But as noted, in these sorts of errors, you will typically find the error very quickly yourself using the debugger.

 

Good luck.

Developer
babakar
Posts: 770
Registered: ‎05-29-2012
My Device: see later

Re: Process 1780056901 (Zain) terminated SIGSEGV code=1 fltno=11 ip=00000000 image upload

My big question I have, how can i translate this fos.write(bos.toByteArray());
entity.addPart("imageFile", new FileBody(tempFile)); i have done in bb6 and android... multipartentity..
into bb10 ...in my post http call