Qt - FreeImage problem

Linux specific forum
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Qt - FreeImage problem

Post by wombats »

I'm not sure if this is a bug. I can't figure out why it's happening.

Code: Select all

If IsImage(*dat\image)
  FreeImage(*dat\image)
EndIf
I'm getting 'Invalid memory access.' on the second line. I can't reproduce it in a small example, but surely the IsImage command should prevent FreeImage from even being executed if the image is invalid? It does the same whether 'image' is an integer or pointer in the structure. No problem at all on macOS and Windows.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Qt - FreeImage problem

Post by #NULL »

Buggy threading code can cause weird things like that.
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: Qt - FreeImage problem

Post by wombats »

I only use threads in certain parts of my program, and no threads are started when I encounter this problem.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Qt - FreeImage problem

Post by #NULL »

Then I don't know. Maybe try if the Purifier detects anything wrong.
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: Qt - FreeImage problem

Post by wombats »

The Purifier doesn't tell me anything. I'm at a loss here. It works fine on Windows and macOS, so all I can think is there's a problem with the FreeImage command, but I can't reproduce it outside of my project.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Qt - FreeImage problem

Post by mk-soft »

No problem here with QT ...

Code: Select all

Structure udtData
  Image.i
EndStructure

Global *MyData.udtData = AllocateStructure(udtData)

*MyData\Image = LoadImage(#PB_Any, #PB_Compiler_Home + "examples/sources/Data/PureBasic.bmp")
If *MyData\Image = 0
  Debug "Error load image"
  End
EndIf
  
If OpenWindow(0, 0, 0, 240, 100, "ButtonImage", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonImageGadget(0, 10, 10, 220, 60, ImageID(*MyData\Image))
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

FreeImage(*MyData\Image)

FreeStructure(*MyData)

Delay(100)

My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Qt - FreeImage problem

Post by Fred »

I took a look at the code, and I don't see something obvious. On Linux, you can compile your app with the '-ds' switch (to keep debug symbol) and run it with 'purify' or 'gdb' to try to get a more precise info.
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: Qt - FreeImage problem

Post by wombats »

I think I've narrowed it down to a problem with CopyImage.
Post Reply