Skip to content
  • 0 Votes
    3 Posts
    279 Views
    ScleaverZer0neS

    @jsulm I just thought of that a moment ago and came here to edit the post and read your answer lol. Thanks tho!

  • 0 Votes
    2 Posts
    365 Views
    JonBJ

    @CybeX
    Well, the debugger shows a as "<not accessible>", so unless its value has been optimized out that seems to be the cause of the SEGV. I admit I don't know how/why, assuming you only put items into fileInfoImageList via the code you show.

    I would start by just checking you can visit/print out all the QFileInfos in your lists before you start the std::sort()?

    I would also force a complete rebuild just to make sure. The placement of the debug breakpoint on line #319 which is blank looks odd to me, it's not supposed to do that....

  • 0 Votes
    3 Posts
    606 Views
    aha_1980A

    Hi @CybeX,

    and to add to @JKSH: you probably want to use GetFinalPathNameByHandleW as this is the UNICODE version.

    Regards

  • 0 Votes
    2 Posts
    390 Views
    Christian EhrlicherC

    What's the benefit of FileSystemModel::getFileInfo()? I would guess your this pointer is a nullptr

  • 0 Votes
    3 Posts
    700 Views
    CybeXC

    @VRonin

    Doing a few (rather simple) tests, I found the following (which confirms your suspicion)

    Works: (but no check box) - this is expected to work

    // create item QListWidgetItem* item = new QListWidgetItem(name, ui->listDriveInfo); // item->setText(name); // item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); // add item to list ui->listDriveInfo->addItem(item);

    this crashes on setFlags() call

    // create item QListWidgetItem* item = new QListWidgetItem(name, ui->listDriveInfo); // item->setText(name); //set checkable and state Qt::ItemFlags localFlags = item->flags(); item->setFlags(localFlags | Qt::ItemIsUserCheckable); item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); // add item to list ui->listDriveInfo->addItem(item);

    but these 2 both work (without setting owning QListWidget)

    // create item QListWidgetItem* item = new QListWidgetItem(name); // item->setText(name); //set checkable and state Qt::ItemFlags localFlags = item->flags(); item->setFlags(localFlags | Qt::ItemIsUserCheckable); item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); // add item to list ui->listDriveInfo->addItem(item);

    and

    // create item QListWidgetItem* item = new QListWidgetItem(); // item->setText(name); //set checkable and state Qt::ItemFlags localFlags = item->flags(); item->setFlags(localFlags | Qt::ItemIsUserCheckable); item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); // add item to list ui->listDriveInfo->addItem(item);

    Testing:

    I create a new application, did exactly the same (add a string and a checkbox) and that work 100%. Create a form, throw on a
    QListWidget and run it with this code.

    QListWidgetItem* item = new QListWidgetItem("New", ui->listWidget); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(Qt::Unchecked); QListWidgetItem* item1 = new QListWidgetItem("New 1", ui->listWidget); item1->setFlags(item->flags() | Qt::ItemIsUserCheckable); item1->setCheckState(Qt::Unchecked); QListWidgetItem* item2 = new QListWidgetItem("New 2", ui->listWidget); item2->setFlags(item->flags() | Qt::ItemIsUserCheckable); item2->setCheckState(Qt::Unchecked); ui->listWidget->addItem(item); ui->listWidget->addItem(item1); ui->listWidget->addItem(item2); connect(ui->listWidget, &QListWidget::itemClicked, this, [this](QListWidgetItem * i) { // Get drive info from driveList int pos = ui->listWidget->row(i); // check state & set state bool active = i->checkState() == Qt::Checked; qDebug() << (active ? "enabled" : "disabled"); });

    So my question is, bug (on whose side) or some setting on my side? Thoughts on what to look for?

  • 0 Votes
    18 Posts
    3k Views
    Y

    @aha_1980
    Thank you so much sir, for giving clear idea on access application or utility without root.