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
HuXu77
Posts: 196
Registered: ‎02-10-2011
My Device: Playbook 16GB and Z10

Not Initialized but should be.

So I am stepping through my code after a breakpoint and I set a QString variable like so:

 

QByteArray arr = reply->readAll();
QString raw = QString(arr);

 

But the problem is, I get past raw and it says its Not Initialized.

 

Why!?

 

Screenshot

_________________________________________________
Apps
Go Music
Flashlight Fast Free/Pro
Fitbit for BlackBerry PlayBook
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Not Initialized but should be.

This should work, but can be simplified to:

QString raw(arr);

Try printing the string with qDebug:

qDebug() << raw << "\n";

Andrey Fidrya, @zmeyc on twitter
Developer
HuXu77
Posts: 196
Registered: ‎02-10-2011
My Device: Playbook 16GB and Z10

Re: Not Initialized but should be.

Thanks, I will use that workaround for now, but I will leave this open without a solution because I would like to know why its not showing up in the Variables view in the IDE because some QString show up just fine, why doesn't this and others?
_________________________________________________
Apps
Go Music
Flashlight Fast Free/Pro
Fitbit for BlackBerry PlayBook
New Developer
pleasereset
Posts: 8
Registered: ‎07-23-2013
My Device: Blackberry Z10

Re: Not Initialized but should be.

I have the very same problem with class members.

 

A class declaring 5 QString members and even explicitly initializing them in the ctor has only its 3 first QString members initialized.

Developer
YamilBracho
Posts: 713
Registered: ‎05-31-2010
My Device: 8520

Re: Not Initialized but should be.

Please publish your hpp (when you declrae your vars) and the ctor code...

New Developer
pleasereset
Posts: 8
Registered: ‎07-23-2013
My Device: Blackberry Z10

Re: Not Initialized but should be.

[ Edited ]

Here are the files :

 

HPP :

 

#ifndef PROGRAMDETAILSCONTEXT_H_
#define PROGRAMDETAILSCONTEXT_H_

#include <QtCore>

class ProgramDetailsContext : public QObject {
	Q_OBJECT
	Q_PROPERTY(bool isBusy READ isBusy NOTIFY isBusyChanged )
	Q_PROPERTY(QString title READ title NOTIFY titleChanged)
	Q_PROPERTY(QString channelImage READ channelImage NOTIFY channelImageChanged)
	Q_PROPERTY(QString channelName READ channelName NOTIFY channelNameChanged)
	Q_PROPERTY(QString summary READ summary NOTIFY summaryChanged)
public:
	ProgramDetailsContext(QObject* parent = 0);
	virtual ~ProgramDetailsContext();

	bool isBusy() { return m_isBusy; }
	QString title() { return m_title; }
	QString channelImage() { return m_channelImage; }
	QString channelName() { return m_channelName; }
	QString summary() { return m_summary; )

	Q_INVOKABLE void setItemId(QString id);

Q_SIGNALS:
	void isBusyChanged();
	void titleChanged();
	void channelImageChanged();
	void channelNameChanged();
	void summaryChanged();

private:
	bool m_isBusy;

	QString m_summary;
	QString m_title;
	QString m_channelImage;
	QString m_channelName;
	QString m_test;
};

 CPP : 

#include "ProgramDetailsContext.h"

ProgramDetailsContext::ProgramDetailsContext(QObject* parent) :
	QObject(parent),
	m_isBusy(false),
	m_title(""),
	m_channelImage(""),
	m_channelName(""),
	m_summary(""),
	m_test(""){

}

 

Developer
YamilBracho
Posts: 713
Registered: ‎05-31-2010
My Device: 8520

Re: Not Initialized but should be.

You have to initialized them in teh same order as your declared. It should be showing you a warning... so change the code in the ctor to :

 

ProgramDetailsContext::ProgramDetailsContext(QObject* parent) 
	: QObject(parent)
	, m_isBusy(false),
	, m_summary(""),
	, m_title(""),
	, m_channelImage(""),
	, m_channelName(""),
	, m_test("") {

}

 

New Developer
pleasereset
Posts: 8
Registered: ‎07-23-2013
My Device: Blackberry Z10

Re: Not Initialized but should be.

The warning is gone (but I think the compiler's options automatically reordered in this case ?), but no difference at runtime, m_summary and m_test are still uninitialized.

 

Then I just scratched my head, cleaned the project and rebuilt from scratch, then "voilà !".

So I'm not sure what did the trick but problem solved :smileyhappy: