Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7577877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:17:52+00:00 2026-05-30T17:17:52+00:00

This really feels like a bug in Qt. Anyone has a solution or should

  • 0

This really feels like a bug in Qt. Anyone has a solution or should I file it as a bug?

#include <QReadWriteLock>

class FileInfoWrapper {

public:
    explicit FileInfoWrapper(const QFileInfo& _fileInfo);
    ~FileInfoWrapper();

private: // also tried public
    mutable QReadWriteLock lock_;

Before even using it, I get the error:

Error 1 error C2248: ‘QReadWriteLock::QReadWriteLock’ : cannot access private member declared in class ‘QReadWriteLock’

Doesn’t matter if it’s private/public or what classes I include. I don’t seem to be able to create it on the stack. Instead I created one on the heap using ‘new’, but when I try to delete it in the constructor my application crashes with:

Unhandled exception at 0x5090f39a (QtCored4.dll) in MyApp.exe: 0xC0000005: Access violation reading location 0xfeeeff0e.

Call stack:

QtCored4.dll!QHash::~QHash() Line 283 + 0xa bytes C++
QtCored4.dll!QReadWriteLockPrivate::~QReadWriteLockPrivate() + 0x38 bytes C++
QtCored4.dll!QReadWriteLockPrivate::`scalar deleting destructor'() + 0xf bytes C++
QtCored4.dll!QReadWriteLock::~QReadWriteLock() Line 137 + 0x1e bytes C++
CloudSync.exe!FileInfoWrapper::~FileInfoWrapper() Line 76 + 0x15 bytes C++

The variable ‘d’ in QReadWriteLockPrivate seems to be deleted twice. However, this works in another class where I also had to create the lock on the heap and then delete it in the constructor.

Running Qt 4.8.0 in Visual Studio. Had the same issue in Qt creator 4.7.4.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:17:53+00:00Added an answer on May 30, 2026 at 5:17 pm

    You have to use a pointer because QReadWriteLock is not copyable (it uses Q_DISABLE_COPY) and you are somehow copying your FileInfoWrapper objects (by storing them in a container for example).
    So the pointer address is shared between those copies, and deleted once for each copy.

    You can wrap the pointer inside a smart pointer, so that deletion will only occur when the last copy of your object is deleted.

    QSharedPointer<QReadWriteLock> lock_;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This feels like it should be really easy, but I just can't get it
This feels like a really basic question, but I can't figure it out anyway..
I feel like there's a simple solution to this, but I'm not really sure
This really seems like a bug to me, but perhaps some databinding gurus can
I have a question that really feels like I should have an easy answer
This feels like a really basic question, but I haven't been able to find
I feel like this might be really simple but I'm just not getting it
This really has my stumped today. I'm sure its simple, but... Here is my
(This looks like a long question, but it's not really, honest!) I am trying
This has been bugging me for years, but I've just been ignoring it, like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.