02-16-2013 03:04 PM
Hello,
I attached code which throws error of duplicate connection name and after they application crash.
Note :- Into app when you press tab3 at that time they fetch data and another time you press tab3 then application crash,
So please update me asap.
Thanks,
Umang.
Solved! Go to Solution.
02-22-2013 03:42 AM
Still waiting for reply You can find attached code or also i include code here
qml
// Default empty project template
import bb.cascades 1.0
TabbedPane {
id: tabMeniuNavigation
//showTabsOnActionBar: true
Tab {
title: qsTr("All")
id: tab1
Page {
Container {
// define tab content here
Label {
text: qsTr("Tab1")
horizontalAlignment: HorizontalAlignment.Center
textStyle {
base: SystemDefaults.TextStyles.TitleText
}
}
}
}
}
Tab {
id: tab2
title: qsTr("Tab2")
Page {
Container {
// define tab content here
Label {
text: qsTr("Tab2")
horizontalAlignment: HorizontalAlignment.Center
textStyle {
base: SystemDefaults.TextStyles.TitleText
}
}
}
}
}
Tab {
id: tab3
title: qsTr("Tab3")
content: Page {
Container {
ListView {
objectName: "otherNoteListView"
} // ListView
}
}
onTriggered: {
app.medicialListData();
}
}
Tab {
id: tab4
title: qsTr("Tab4")
Page {
Container {
// define tab content here
Label {
text: qsTr("Tab 4")
horizontalAlignment: HorizontalAlignment.Center
textStyle {
base: SystemDefaults.TextStyles.TitleText
}
}
}
}
}
Tab {
id: tab5
title: qsTr("Tab5")
Page {
Container {
// define tab content here
Label {
text: qsTr("Tab5")
horizontalAlignment: HorizontalAlignment.Center
textStyle {
base: SystemDefaults.TextStyles.TitleText
}
}
}
}
}
onCreationCompleted: {
// this slot is called when declarative scene is created
// write post creation initialization here
console.log("TabbedPane - onCreationCompleted()")
// enable layout to adapt to the device rotation
// don't forget to enable screen rotation in bar-bescriptor.xml (Application->Orientation->Auto-orient)
OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
}
}
cpp
// Default empty project template
#include "FindMedicin.hpp"
#include "customListMedicinitemfactory.h"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <bb/data/DataAccessError.hpp>
using namespace bb::cascades;
using namespace bb::data;
FindMedicin::FindMedicin(bb::cascades::Application *app) :
QObject(app) {
// create scene document from main.qml asset
// set parent to created document to ensure it exists for the whole application lifetime
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(th is);
qml->setContextProperty("app", this);
// create root object for the UI
root = qml->createRootObject<AbstractPane>();
// set created root object as a scene
app->setScene(root);
}
FindMedicin::~FindMedicin() {
QSqlDatabase::removeDatabase(mDbNameWithPath);
delete medicinListView;
model->registerUserData();
}
QString FindMedicin::copyFileToDataFolder(const QString fileName) {
// Since we need read and write access to the file, it has
// to be moved to a folder where we have access to it. First,
// we check if the file already exists (previously copied).
QString dataFolder = QDir::homePath();
QString newFileName = dataFolder + "/" + fileName;
QFile newFile(newFileName);
if (!newFile.exists()) {
// If the file is not already in the data folder, we copy it from the
// assets folder (read only) to the data folder (read and write).
QString appFolder(QDir::homePath());
appFolder.chop(4);
QString originalFileName = appFolder + "app/native/assets/" + fileName;
QFile originalFile(originalFileName);
if (originalFile.exists()) {
// Create sub folders if any creates the SQL folder for a file path like e.g. sql/quotesdb
QFileInfo fileInfo(newFileName);
QDir().mkpath(fileInfo.dir().path());
if (!originalFile.copy(newFileName)) {
qDebug() << "Failed to copy file to path: " << newFileName;
}
} else {
qDebug() << "Failed to copy file data base file does not exists.";
}
}
return newFileName;
}
//Find Pharama
void FindMedicin::medicialListData() {
CustomListMedicinItemFactory *otherNoteItemFactory =
new CustomListMedicinItemFactory();
qDebug() << "MediaList Data Called.";
// create a data model with sorting keys for firstname and lastname
model = new GroupDataModel(QStringList() << "field1");
mDbNameWithPath = copyFileToDataFolder("sql/FindMedicin.db");
// load the sql data from contacts table
SqlDataAccess sda(mDbNameWithPath);
//sda = new SqlDataAccess(mDbNameWithPath, this);
if (sda.hasError()) {
DataAccessError err = sda.error();
//DataAccessError* err = sda.error();
qWarning() << "SQL error: type=" << err.errorType() << ": "
<< err.errorMessage();
}
QVariant list = sda.execute("select * from medicin_detail");
// add the data to the model
qDebug() << list.value<QVariantList>();
model->setGrouping(ItemGrouping::None);
model->insertList(list.value<QVariantList>());
// create a ListView control and add the model to the list
medicinListView = root->findChild<ListView*>("otherNoteListView");
medicinListView->setObjectName("");
medicinListView->setDataModel(model);
medicinListView->setListItemProvider(otherNoteItem Factory);
}
more code into attachement.
02-22-2013 09:08 AM
Could you provide a more concise sample or code snippet where this issue occurs?
It may also help to know the OS version and SDK version being used.
02-22-2013 09:18 AM
Hi,
First time all data set into listview but after i click into same tab at that time data load but application crash.
And i show log so below message i got
02-22-2013 09:22 AM
It could be due to trying to create a new database connection every time that tab is brought up. Debugging the medicialListData() method should let you see if this is happening.
If you still have issues could you please provide a simplified sample, possibly with only one tab and as little C+ as needed to reproduce the issue? It should make understanding the cause much easier.
02-22-2013 09:35 AM
02-22-2013 09:53 AM