Saving footprint in pcb footprint library editor crashes on linux

Bug #1042554 reported by kuba.fra
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Undecided
Unassigned

Bug Description

When saving footprint to my new footprints library (*.mod) on linux I've received following error:

IO_ERROR: Unable to rename tempfile '/tmp/EMDR_LightFootAdLpsC' to to library file 'EMDR_LightFoot.mod'
from /build/buildd/kicad-0.0.201208262046+3684~10~lucid1/kicad/pcbnew/legacy_plugin.cpp : Save() : line 4128

At first I've checked access permissions to /tmp directory and my project directory.

Then I've checked this part of code and there is a function:

if( wxRename( tempFileName, m_lib_name ) )
{
    THROW_IO_ERROR( wxString::Format(
     _( "Unable to rename tempfile '%s' to to library file '%s'" ),
     tempFileName.GetData(),
     m_lib_name.GetData() ) );
}

The function wxRename returns different results on Windows, MacOs and Linux.

Consider this function: wxRenameFile
http://docs.wxwidgets.org/stable/wx_filefunctions.html#wxrenamefile

Revision history for this message
Lorenzo Marcantonio (l-marcantonio) wrote : Re: [Bug 1042554] [NEW] Saving footprint in pcb footprint library editor crashes on linux

On Tue, Aug 28, 2012 at 06:09:32AM -0000, kuba.fra wrote:
> The function wxRename returns different results on Windows, MacOs and
> Linux.

Yay for portability XD this almost beats the hashtable issue...

--
Lorenzo Marcantonio
Logos Srl

Revision history for this message
Dick Hollenbeck (dickelbeck) wrote :

On 08/28/2012 01:09 AM, kuba.fra wrote:
> Public bug reported:
>
> When saving footprint to my new footprints library (*.mod) on linux I've
> received following error:
>
> IO_ERROR: Unable to rename tempfile '/tmp/EMDR_LightFootAdLpsC' to to library file 'EMDR_LightFoot.mod'
> from /build/buildd/kicad-0.0.201208262046+3684~10~lucid1/kicad/pcbnew/legacy_plugin.cpp : Save() : line 4128
>
> At first I've checked access permissions to /tmp directory and my
> project directory.
>
> Then I've checked this part of code and there is a function:
>
> if( wxRename( tempFileName, m_lib_name ) )
> {
> THROW_IO_ERROR( wxString::Format(
> _( "Unable to rename tempfile '%s' to to library file '%s'" ),
> tempFileName.GetData(),
> m_lib_name.GetData() ) );
> }
>
> The function wxRename returns different results on Windows, MacOs and
> Linux.

Please tell me how you know this last statement, such as a documentation reference or
source code line. I run linux and am not seeing your error for example.

>
> Consider this function: wxRenameFile
> http://docs.wxwidgets.org/stable/wx_filefunctions.html#wxrenamefile

UI functions are not allowed in a plugin, and wxRemoveFile() puts up a dialog under some
circumstances.

Can you please verify that wxRenameFile will never puts up a dialog function under any
circumstances. This means checking the source code to wx.

Revision history for this message
Dick Hollenbeck (dickelbeck) wrote :

On 08/28/2012 01:09 AM, kuba.fra wrote:
> Public bug reported:
>
> When saving footprint to my new footprints library (*.mod) on linux I've
> received following error:
>
> IO_ERROR: Unable to rename tempfile '/tmp/EMDR_LightFootAdLpsC' to to library file 'EMDR_LightFoot.mod'

I wonder why there is no matching path on the front of

  'EMDR_LightFoot.mod'

Is this the exact text of error message?

If so, then perhaps there is a bug in wxFilename::CreateTempFileName(), or in my use of it.

Revision history for this message
Dick Hollenbeck (dickelbeck) wrote :

On 08/28/2012 08:38 AM, Dick Hollenbeck wrote:
> On 08/28/2012 01:09 AM, kuba.fra wrote:
>> Public bug reported:
>>
>> When saving footprint to my new footprints library (*.mod) on linux I've
>> received following error:
>>
>> IO_ERROR: Unable to rename tempfile '/tmp/EMDR_LightFootAdLpsC' to to library file 'EMDR_LightFoot.mod'
> I wonder why there is no matching path on the front of
>
> 'EMDR_LightFoot.mod'
>
>
> Is this the exact text of error message?
>
> If so, then perhaps there is a bug in wxFilename::CreateTempFileName(), or in my use of it.

The docs say this:

"Returns a temporary file name starting with the given /prefix/. If the /prefix/ is an
absolute path, the temporary file is created in this directory, otherwise it is created in
the default system directory for the temporary files or in the current directory."

So what seems to be causing this problem is the fact that there is no preceding path on
your m_lib_name variable.

Go figure.

Revision history for this message
kuba.fra (kuba-fra) wrote :

I've found this message:
http://trac.wxwidgets.org/ticket/11228

I run wxWidgets 2.8.10 Linux, Unicode. (Ubuntu 10.04) I will try to recreate this problem on my private pc (ubuntu 11.10) and confirm this (or not ;) )

i'm checingout source code from wx svn and i'm going to check how does wxRename and wxRenameFile work.

Revision history for this message
Dick Hollenbeck (dickelbeck) wrote :

You ran into one of my least favorite features of KiCad, the "library search path".

I am hoping to see this replaced soon with a library table, so no searching or guessing is
required.

I don't know what you did to end up with a library name that had no preceding path, but it
does not surprise me that you did, since the library search path concepts and dialogs are
as confusing as they are.

Until we have library table support,

if you can build with this patch, please do, and test the case where there is no preceding
path on the library. (I already tested this for the case where a path is present, the
normal case, and it works.)

Revision history for this message
kuba.fra (kuba-fra) wrote :

Library name was exact the same (without full path name, only 'EMDR_LightFoot.mod')
How do I get this error:
1. Open KiCad
2. Open my recent project (*.pro file)
3. Open Pcbnew
4. Open footprint editor
5. Click: new footprint and enter its name
6. Create new library and save current footprint
7. Enter my library name when asked: EMDR_LightFoot.mod (saved in project folder, without any subfolders)
8. Close footprint editor
9. In Pcbnew: Settings->Library
10. Add library: just created .mod file -> OK
11. Open footprint editor again
12. Chose active library -> select form list my just added library
13. Add some parts to current footprint
14. Save footprint in current library
15. Confirm footprint name
16. Error dialog shows up:
IO_ERROR: Nie mogę zmienić nazwy pliku tymczasowego '/tmp/EMDR_LightFoot7PqTFF' na nazwę pliku biblioteki 'EMDR_LightFoot.mod'
from /build/buildd/kicad-0.0.201208202219+3676~10~oneiric1/kicad/pcbnew/legacy_plugin.cpp : Save() : line 4128
(I'm form Poland, message in original language, means: cannot rename temporary file....)

Now checked on Ubuntu 11.10.

Maybe I cannot create new library with new footprints in proper way.

@dickelbeck: I cannot apply your path and recompile KiCad now (don't have so much time) If it is necessary I will do this in a few days.

Revision history for this message
Dick Hollenbeck (dickelbeck) wrote : Re: [Bug 1042554] Re: Saving footprint in pcb footprint library editor crashes on linux

Thanks for the detailed step by step instructions.

When I follow those, I still get a preceding path on m_lib_name, according to the
wxDebugLog() statement I put in there on line 4104.

So I am unable to wrestle with "library search paths" any more. It seems my distaste for
this feature has gotten the better of me.

The patch has been committed, but I would not mark this bug as fixed until somebody can do
a Debug build and actually see line
4104 show him/her a m_lib_path with no preceding path.

This will then have verified it is YOUR test case, and the bug could be marked as fixed at
that point.

Revision history for this message
Dick Hollenbeck (dickelbeck) wrote :

patch committed in revision 3688

Revision history for this message
kuba.fra (kuba-fra) wrote :

Some additional info:

This error appears only when just edited library is in current project folder and this library is added to project with relative path (this means: there is only library name in project library list)

Walk around:
Create second, empty project only for editing libraries for first project. In second project do not use relative paths. This works for me.

Revision history for this message
Dick Hollenbeck (dickelbeck) wrote :

On 08/31/2012 02:12 AM, kuba.fra wrote:
> Some additional info:
>
> This error appears only when just edited library is in current project
> folder and this library is added to project with relative path (this
> means: there is only library name in project library list)
>
> Walk around:
> Create second, empty project only for editing libraries for first project. In second project do not use relative paths. This works for me.

Test and report on the new version only.
It is my view that the bug is very likely fixed. Confirm or disprove only that please.

Revision history for this message
kuba.fra (kuba-fra) wrote :

I've updated KiCad (to b3709) today from daily-build Adam Wolf's ppa repository and it works good for me now!!!

Thank You for your great work.

Changed in kicad:
status: New → Fix Committed
Revision history for this message
David Cox (cox-spirail) wrote :

Hi. I wasn't getting this exact problem and now I am.

Perhaps it has been reintroduced? I have Build: 2012-oct-18-testing

Revision history for this message
Dick Hollenbeck (dickelbeck) wrote :

> On 11/13/2012 01:47 AM, David Cox wrote:
> Hi. I wasn't getting this exact problem and now I am.
>
> Perhaps it has been reintroduced? I have Build: 2012-oct-18-testing
>

We're working on footprint library tables now, which will gut the library path code out,
so it would be a waste of time looking into this for me.

I won't do it. Wait, and it will likely go away with library table support. Or submit a
detailed bug report and hope somebody else will provide a short lived fix.
Your statements above would be inadequate to track this down, insufficient detail. But
don't waste your time.

Revision history for this message
David Cox (cox-spirail) wrote :

Ok, well good to know there are people developing Kicad, anyway. So far i think its pretty good.

I read though all the comments in here and it didn't help me much.

My work-around was to just make a file and fill it with the following code.
Now you have a lib with just one part, which is a hole.
Add your modules to this lib. Later on you can edit the file and delete the hole part of the module.

Let us know if it works for you.

PCBNEW-LibModule-V1 Tue 13 Nov 2012 07:16:15 PM CET
# encoding utf-8
Units mm
$INDEX
hole
$EndINDEX
$MODULE hole
Po 0 0 0 15 50A28E6A 00000000 ~~
Li hole
Sc 0
AR
Op 0 0 0
T0 0 0 1 1 0 0.15 N V 21 N "hole"
T1 0 0 1 1 0 0.15 N V 21 N "VAL**"
$PAD
Sh "1" C 8.1 8.1 0 0 0
Dr 8 0 0
At STD N 00E0FFFF
Ne 0 ""
Po 0 0
$EndPAD
$EndMODULE hole
$EndLIBRARY

Revision history for this message
David Cox (cox-spirail) wrote :

And... i still needed the absolute value for the search path. Not the relative one. But it was fine to use the same project and a sub-folder in that project.

Jon Neal (reportingsjr)
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.